1998-10-09 Nathan Bryant <bryant@cs.usm.maine.edu>
* serv_chat.c: fix buffer overrun that was resulting in segv's
+ * serv_chat.c: fix another overrun that could cause sessions to hang,
+ and cleaned up some other strncpy()-related stuff. DON'T FORGET TO
+ NULL-TERMINATE DESTINATION BUFFERS AFTER STRNCPY CALLS.
Fri Oct 9 13:22:37 EDT 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Implemented "lazy mode" traversal - pressing the space bar will do
strncpy(clnew->chat_room, roomname, sizeof clnew->chat_room);
clnew->chat_room[sizeof clnew->chat_room - 1] = 0;
if (username)
- strncpy(clnew->chat_username, username, 31);
+ {
+ strncpy(clnew->chat_username, username,
+ sizeof clnew->chat_username);
+ clnew->chat_username[sizeof clnew->chat_username - 1] = 0;
+ }
else
clnew->chat_username[0] = '\0';
strcpy(clnew->chat_text, bcast);
strcpy(CC->chat_room, "Main room");
else
{
- strncpy(CC->chat_room, &cmdbuf[6], ROOMNAMELEN);
+ strncpy(CC->chat_room, &cmdbuf[6],
+ sizeof CC->chat_room);
+ CC->chat_room[sizeof CC->chat_room - 1] = 0;
}
allwrite("<joining room>",0, CC->chat_room, NULL);
cprintf("\n");