]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_chat.c
* added RCS Id keyword strings to sources
[citadel.git] / citadel / serv_chat.c
index f11aec85bbb83ffa5b303e58b9f848d3cd7290de..022ce07aaaa92d76734b13a130e326cc049fbce1 100644 (file)
@@ -1,3 +1,4 @@
+/* $Id$ */
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
@@ -14,7 +15,7 @@
 #include "citadel.h"
 #include "server.h"
 #include <syslog.h>
-#ifdef NEED_SELECT_H
+#ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
 #endif
 #include "serv_chat.h"
@@ -86,7 +87,7 @@ void allwrite(char *cmdbuf, int flag, char *roomname, char *username)
                }
 
        clnew = (struct ChatLine *) malloc(sizeof(struct ChatLine));
-       bzero(clnew, sizeof(struct ChatLine));
+       memset(clnew, 0, sizeof(struct ChatLine));
        if (clnew == NULL) {
                fprintf(stderr, "citserver: cannot alloc chat line: %s\n",
                        strerror(errno));
@@ -96,9 +97,14 @@ void allwrite(char *cmdbuf, int flag, char *roomname, char *username)
        time(&now);
        clnew->next = NULL;
        clnew->chat_time = now;
-       strncpy(clnew->chat_room, roomname, ROOMNAMELEN-1);
+       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);
@@ -309,7 +315,9 @@ void cmd_chat(char *argbuf)
                              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");