Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv27604/src
Modified Files:
Tag: rel-1_0
hash.h hash.c
Log Message:
fix possible bug in (unused) callback function, and comment why it's a hazard
Index: hash.h
===================================================================
RCS file: /cvsroot/srvx/services/src/hash.h,v
retrieving revision 1.52.2.10
retrieving revision 1.52.2.11
diff -C2 -r1.52.2.10 -r1.52.2.11
*** hash.h 2001/09/04 18:39:36 1.52.2.10
--- hash.h 2001/10/12 03:42:02 1.52.2.11
***************
*** 190,194 ****
void DelUser(userNode* user, userNode *killer, int announce, const char *why);
void ReintroduceUser(userNode* user);
! typedef void (*nick_change_func_t)(struct userNode *user, const char *oldnick);
void reg_nick_change_func(nick_change_func_t handler);
void NickChange(userNode* user, const char *new_nick);
--- 190,194 ----
void DelUser(userNode* user, userNode *killer, int announce, const char *why);
void ReintroduceUser(userNode* user);
! typedef void (*nick_change_func_t)(struct userNode *user, const char *new_nick);
void reg_nick_change_func(nick_change_func_t handler);
void NickChange(userNode* user, const char *new_nick);
Index: hash.c
===================================================================
RCS file: /cvsroot/srvx/services/src/hash.c,v
retrieving revision 1.121.2.15
retrieving revision 1.121.2.16
diff -C2 -r1.121.2.15 -r1.121.2.16
*** hash.c 2001/09/04 21:30:19 1.121.2.15
--- hash.c 2001/10/12 03:42:02 1.121.2.16
***************
*** 492,496 ****
void NickChange(userNode* user, const char *new_nick)
{
- char old_nick[NICKLEN+1];
unsigned int nn;
--- 492,495 ----
***************
*** 501,508 ****
dict_remove(clients, user->nick);
! /* save old nick for callbacks */
! safestrncpy(old_nick, user->nick, sizeof(old_nick));
! /* copy new nick */
safestrncpy(user->nick, new_nick, sizeof(user->nick));
--- 500,514 ----
dict_remove(clients, user->nick);
! /* Make callbacks for nick changes.
! * This needs to be done with the old nick still in place, else
! * dict lookups based on user->nick will miss the user.
! * It is safe to re-insert using new_nick (which may be a
! * temporary pointer) since the later value of user->nick will be
! * correct. */
! for (nn=0; nn<ncf2_used; nn++) {
! ncf2_list[nn](user, new_nick);
! }
! /* copy new nick into struct */
safestrncpy(user->nick, new_nick, sizeof(user->nick));
***************
*** 512,519 ****
if (IsLocal(user->numeric)) irc_nick(user);
- /* make callbacks */
- for (nn=0; nn<ncf2_used; nn++) {
- ncf2_list[nn](user, old_nick);
- }
}
--- 518,521 ----
|