[623] in Zephyr_Bugs
Re: serious bug in brain dump code (zephyr 2.0 beta 2)
daemon@ATHENA.MIT.EDU (Greg Hudson)
Tue Jul 11 22:08:21 1995
Date: Tue, 11 Jul 1995 22:08:05 -0400
From: Greg Hudson <ghudson@MIT.EDU>
To: "E. Jay Berkenbilt" <ejb@ERA.COM>
Cc: bug-zephyr@MIT.EDU
In-Reply-To: "[622] in Zephyr_Bugs"
> The brain dump code in the zephyr server is currently seriously
> flawed. If you have two servers, and one is killed and restarted,
> when it reloads its information from the other server, it shows all
> clients to be at the other server rather than where they really are.
Here's a patch for this. In addition to this patch, you should edit
lib/ZParseNot.c and, in the loop where it sets z_other_fields[], get
rid of the extra "numfields--" in the loop. Otherwise brain dumps
will stop working altogether.
(This library fix does not need to be propagated to the clients, since
no other part of the protocol currently uses the "other fields".)
Index: server/bdump.c
===================================================================
RCS file: /mit/zephyr/src/CVS/zephyr/server/bdump.c,v
retrieving revision 1.52
diff -c -r1.52 bdump.c
*** 1.52 1995/07/08 02:48:43
--- bdump.c 1995/07/12 00:09:21
***************
*** 579,592 ****
char *class_name, *inst, *opcode, *sender, *recip, **lyst;
{
ZNotice_t notice;
! char *pack;
int packlen, count;
Code_t retval;
u_short length;
notice.z_kind = kind;
- memcpy(¬ice.z_sender_addr, &addr->sin_addr, sizeof(struct sockaddr_in));
notice.z_port = addr->sin_port;
notice.z_class = class_name;
notice.z_class_inst = inst;
--- 579,596 ----
char *class_name, *inst, *opcode, *sender, *recip, **lyst;
{
ZNotice_t notice;
! char *pack, addrbuf[100];
int packlen, count;
Code_t retval;
u_short length;
+ retval = ZMakeAscii(addrbuf, sizeof(addrbuf),
+ (unsigned char *) &addr->sin_addr,
+ sizeof(struct in_addr));
+ if (retval != ZERR_NONE)
+ return retval;
notice.z_kind = kind;
notice.z_port = addr->sin_port;
notice.z_class = class_name;
notice.z_class_inst = inst;
***************
*** 594,600 ****
notice.z_sender = sender;
notice.z_recipient = recip;
notice.z_default_format = "";
! notice.z_num_other_fields = 0;
retval = ZFormatNoticeList(¬ice, lyst, num, &pack, &packlen, ZNOAUTH);
if (retval != ZERR_NONE)
--- 598,605 ----
notice.z_sender = sender;
notice.z_recipient = recip;
notice.z_default_format = "";
! notice.z_num_other_fields = 1;
! notice.z_other_fields[0] = addrbuf;
retval = ZFormatNoticeList(¬ice, lyst, num, &pack, &packlen, ZNOAUTH);
if (retval != ZERR_NONE)
***************
*** 820,828 ****
syslog(LOG_DEBUG, buf);
}
#endif /* DEBUG */
who.sin_family = AF_INET;
- who.sin_addr.s_addr = notice.z_sender_addr.s_addr;
who.sin_port = notice.z_port;
if (strcmp(notice.z_opcode, ADMIN_DONE) == 0) {
/* end of brain dump */
return ZERR_NONE;
--- 825,846 ----
syslog(LOG_DEBUG, buf);
}
#endif /* DEBUG */
+ if (notice.z_num_other_fields >= 1) {
+ retval = ZReadAscii(notice.z_other_fields[0],
+ strlen(notice.z_other_fields[0]),
+ (unsigned char *) &who.sin_addr,
+ sizeof(struct in_addr));
+ if (retval != ZERR_NONE) {
+ syslog(LOG_ERR, "brl zreadascii failed: %s",
+ error_message(retval));
+ return retval;
+ }
+ } else {
+ who.sin_addr.s_addr = notice.z_sender_addr.s_addr;
+ }
who.sin_family = AF_INET;
who.sin_port = notice.z_port;
+
if (strcmp(notice.z_opcode, ADMIN_DONE) == 0) {
/* end of brain dump */
return ZERR_NONE;
***************
*** 847,854 ****
if (*notice.z_class_inst) {
/* a C_Block is there */
cp = notice.z_message + strlen(notice.z_message) + 1;
! retval = ZReadAscii(cp, strlen(cp), cblock, sizeof(C_Block),
! sizeof(C_Block));
if (retval != ZERR_NONE) {
syslog(LOG_ERR,"brl bad cblk read: %s (%s)",
error_message(retval), cp);
--- 865,871 ----
if (*notice.z_class_inst) {
/* a C_Block is there */
cp = notice.z_message + strlen(notice.z_message) + 1;
! retval = ZReadAscii(cp, strlen(cp), cblock, sizeof(C_Block));
if (retval != ZERR_NONE) {
syslog(LOG_ERR,"brl bad cblk read: %s (%s)",
error_message(retval), cp);