- pass -Wcast-qual to gcc
authorNathan Bryant <loanshark@uncensored.citadel.org>
Tue, 12 Mar 2002 01:33:42 +0000 (01:33 +0000)
committerNathan Bryant <loanshark@uncensored.citadel.org>
Tue, 12 Mar 2002 01:33:42 +0000 (01:33 +0000)
 - more sprintf bashing

19 files changed:
citadel/ChangeLog
citadel/configure.ac
citadel/internet_addressing.c
citadel/internet_addressing.h
citadel/locate_host.c
citadel/messages.c
citadel/routines.c
citadel/routines.h
citadel/routines2.c
citadel/sendcommand.c
citadel/serv_bio.c
citadel/serv_expire.c
citadel/serv_imap.c
citadel/serv_network.c
citadel/serv_pop3.c
citadel/serv_smtp.c
citadel/server_main.c
citadel/tools.c
citadel/tools.h

index 5b1627b96e305582233cb39ba645831218ee8830..114dc091d1d72780b666307c31be85a37b14b922 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 590.140  2002/03/12 01:33:42  nbryant
+  - pass -Wcast-qual to gcc
+  - more sprintf bashing
+
  Revision 590.139  2002/03/12 00:03:43  nbryant
  more sprintf removals
 
@@ -3437,3 +3441,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
+
index 7b3452b21c8c84118a0bcbcc2aa62cf7f7647dbb..14083d78afc052fbb6e96d5387f6be51023b11a1 100644 (file)
@@ -100,10 +100,10 @@ dnl Set up system-dependent compiler flags.
 if test "$GCC" = yes; then
        case "$host" in
                *-*-solaris*|alpha*-dec-osf*)
-                       CFLAGS="$CFLAGS -Wall -Wcast-align -Wno-char-subscripts"
+                       CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wno-char-subscripts"
                ;;
                *)
-                       CFLAGS="$CFLAGS -Wall -Wcast-align -Wstrict-prototypes"
+                       CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wstrict-prototypes"
                ;;
        esac
 fi
index 741c563fe5ae9196ecd069e2e58580b69fc74a3f..93337b3b166fa006461fdd179f5d62fa1bd6198e 100644 (file)
@@ -157,7 +157,7 @@ void unfold_rfc822_field(char *field) {
  * Split an RFC822-style address into userid, host, and full name
  *
  */
-void process_rfc822_addr(char *rfc822, char *user, char *node, char *name)
+void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name)
 {
        int a;
 
index d873b972dd5bf738c6192ff63b27f761d3a10316..42b7c5bd11ef40100d3897816ec3cc3d2474dad7 100644 (file)
@@ -14,7 +14,7 @@ struct internet_address_list {
 
 
 int fuzzy_match(struct usersupp *us, char *matchstring);
-void process_rfc822_addr(char *rfc822, char *user, char *node, char *name);
+void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name);
 char *rfc822_fetch_field(char *rfc822, char *fieldname);
 
 int IsDirectory(char *addr);
index f7878684352db5ced117d24a5ce664de8d461e7d..7e30b46f2aea6732dc06b88b44812ef6a38ce889 100644 (file)
@@ -31,7 +31,8 @@
 void locate_host(char *tbuf, size_t n, const struct in_addr *addr)
 {
        struct hostent *ch;
-       char *i;
+       const char *i;
+       char *j;
        int a1, a2, a3, a4;
 
        lprintf(9, "locate_host() called\n");
@@ -40,10 +41,10 @@ void locate_host(char *tbuf, size_t n, const struct in_addr *addr)
        begin_critical_section(S_NETDB);
 #endif
 
-       if ((ch = gethostbyaddr((char *) addr, sizeof(*addr), AF_INET)) ==
+       if ((ch = gethostbyaddr((const char *) addr, sizeof(*addr), AF_INET)) ==
            NULL) {
              bad_dns:
-               i = (char *) addr;
+               i = (const char *) addr;
                a1 = ((*i++) & 0xff);
                a2 = ((*i++) & 0xff);
                a3 = ((*i++) & 0xff);
@@ -53,9 +54,9 @@ void locate_host(char *tbuf, size_t n, const struct in_addr *addr)
                                   section */
        }
        /* check if the forward DNS agrees; if not, they're spoofing */
-       i = strdoop(ch->h_name);
-       ch = gethostbyname(i);
-       phree(i);
+       j = strdoop(ch->h_name);
+       ch = gethostbyname(j);
+       phree(j);
        if (ch == NULL)
                goto bad_dns;
 
index 8da83b3cc64f28003a4d3caab6cd7011b68059fe..1a4e6308b93ae518a961b2ceddbcf6b707126fa1 100644 (file)
@@ -50,7 +50,7 @@ struct cittext {
 };
 
 void sttybbs(int cmd);
-int haschar(char *st, int ch);
+int haschar(const char *st, int ch);
 int checkpagin(int lp, int pagin, int height);
 void getline(char *string, int lim);
 void formout(char *name);
index 55e8f94d28d0f9f56a2e6741669ad6efbe560c6e..c3c9f65743bbd8fe9f0619e1dd9852b2dbe6757f 100644 (file)
@@ -122,14 +122,14 @@ void edituser(void)
        int newnow = 0;
 
        newprompt("User name: ",who,25);
-AGUP:  sprintf(buf,"AGUP %s",who);
+AGUP:  snprintf(buf, sizeof buf, "AGUP %s",who);
        serv_puts(buf);
        serv_gets(buf);
        if (buf[0]!='2') {
                scr_printf("%s\n",&buf[4]);
                scr_printf("Do you want to create this user? ");
                if (yesno()) {
-                       sprintf(buf, "CREU %s", who);
+                       snprintf(buf, sizeof buf, "CREU %s", who);
                        serv_puts(buf);
                        serv_gets(buf);
                        if (buf[0] == '2') {
@@ -171,7 +171,7 @@ AGUP:       sprintf(buf,"AGUP %s",who);
        userpurge = intprompt("Purge time (in days, 0 for system default",
                                userpurge, 0, INT_MAX);
 
-       sprintf(buf, "ASUP %s|%s|%d|%d|%d|%d|%ld|%ld|%d",
+       snprintf(buf, sizeof buf, "ASUP %s|%s|%d|%d|%d|%d|%ld|%ld|%d",
                who, pass, flags, timescalled, posted, axlevel, usernum,
                (long)lastcall, userpurge);
        serv_puts(buf);
@@ -213,7 +213,7 @@ void enter_config(int mode)
        int width, height, flags, filter;
        char buf[128];
 
-       sprintf(buf,"GETU");
+       snprintf(buf, sizeof buf, "GETU");
        serv_puts(buf);
        serv_gets(buf);
        if (buf[0]!='2') {
@@ -283,7 +283,7 @@ void enter_config(int mode)
                }
         }
 
-       sprintf(buf,"SETU %d|%d|%d|%d",width,height,flags,filter);
+       snprintf(buf, sizeof buf, "SETU %d|%d|%d|%d",width,height,flags,filter);
        serv_puts(buf);
        serv_gets(buf);
        if (buf[0]!='2') scr_printf("%s\n",&buf[4]);
@@ -380,7 +380,7 @@ char *strerror(int e)
 {
        static char buf[128];
 
-       sprintf(buf,"errno = %d",e);
+       snprintf(buf, sizeof buf, "errno = %d",e);
        return(buf);
        }
 #endif
@@ -558,7 +558,7 @@ int nukedir(char *dirname)
                }
 
        while (d = readdir(dp), d != NULL) {
-               sprintf(filename, "%s/%s", dirname, d->d_name);
+               snprintf(filename, sizeof filename, "%s/%s", dirname, d->d_name);
                unlink(filename);
                }
 
index 8e37f89762e3f74f290d52b490d91ba2a6b6de4e..af723b6945154191effd03707957e35ccdb9913a 100644 (file)
@@ -10,3 +10,4 @@ int nukedir(char *dirname);
 int num_parms(char *source);
 void strproc(char *string);
 void back(int spaces);
+void progress(long int curr, long int cmax);
index dd314c96493ab76fa2fcaedba40327347dc1687a..e66ac3ce0deb2a7256fb6e01e883083ee41a8083 100644 (file)
 #include "snprintf.h"
 #endif
 #include "screen.h"
-
-void interr(int errnum);
-void strprompt(char *prompt, char *str, int len);
-void newprompt(char *prompt, char *str, int len);
-void sttybbs(int cmd);
-int inkey(void);
-void serv_write(char *buf, int nbytes);
-int haschar(char *st, int ch);
-void progress(long int curr, long int cmax);
-int yesno(void);
+#include "client_crypto.h"
 
 extern char temp[];
 extern char tempdir[];
index 0ea558c065fb289df2270e8a9eaac01c17f9bcc0..01b4d5730ca459694722f7bae7ae8c7206784c6a 100644 (file)
@@ -111,7 +111,7 @@ void np_attach_to_server(void)
        attach_to_server(1, args, hostbuf, portbuf);
        serv_gets(buf);
        fprintf(stderr, "%s\n", &buf[4]);
-       sprintf(buf, "IPGM %d", config.c_ipgm_secret);
+       snprintf(buf, sizeof buf, "IPGM %d", config.c_ipgm_secret);
        serv_puts(buf);
        serv_gets(buf);
        fprintf(stderr, "%s\n", &buf[4]);
index 635a48ed027eac6c75295e921a01b93b66c582df..b8f812a3c561b32b384bfb0d307f451571986580 100644 (file)
@@ -60,7 +60,7 @@ void cmd_ebio(char *cmdbuf) {
                return;
        }
 
-       sprintf(buf,"./bio/%ld",CC->usersupp.usernum);
+       snprintf(buf, sizeof buf, "./bio/%ld",CC->usersupp.usernum);
        fp = fopen(buf,"w");
        if (fp == NULL) {
                cprintf("%d Cannot create file\n",ERROR);
@@ -87,7 +87,7 @@ void cmd_rbio(char *cmdbuf)
                cprintf("%d No such user.\n",ERROR+NO_SUCH_USER);
                return;
        }
-       sprintf(buf,"./bio/%ld",ruser.usernum);
+       snprintf(buf, sizeof buf, "./bio/%ld",ruser.usernum);
        
        cprintf("%d OK|%s|%ld|%d|%ld|%ld|%ld\n", LISTING_FOLLOWS,
                ruser.fullname, ruser.usernum, ruser.axlevel,
index 13a18636fae448b6c424ed5447e22d6c9d3e0317..7c9965ad54cbd14f01f06a134e1a4ef40675a54b 100644 (file)
@@ -335,7 +335,7 @@ int PurgeRooms(void) {
        while (RoomPurgeList != NULL) {
                if (getroom(&qrbuf, RoomPurgeList->name) == 0) {
                        transcript=reallok(transcript, strlen(transcript)+SIZ);
-                       sprintf(&transcript[strlen(transcript)], " %s\n",
+                       snprintf(&transcript[strlen(transcript)], SIZ, " %s\n",
                                qrbuf.QRname);
                        delete_room(&qrbuf);
                }
@@ -433,7 +433,7 @@ int PurgeUsers(void) {
 
        while (UserPurgeList != NULL) {
                transcript=reallok(transcript, strlen(transcript)+SIZ);
-               sprintf(&transcript[strlen(transcript)], " %s\n",
+               snprintf(&transcript[strlen(transcript)], SIZ, " %s\n",
                        UserPurgeList->name);
                purge_user(UserPurgeList->name);
                pptr = UserPurgeList->next;
index 381649b9d47e4b689257e9d7d210a029b91aa514..b3804ffbe8e9a66d03af434264e38e4f6a418ac1 100644 (file)
@@ -543,7 +543,7 @@ void imap_lsub(int num_parms, char *parms[]) {
                cprintf("%s BAD arguments invalid\r\n", parms[0]);
                return;
        }
-       sprintf(pattern, "%s%s", parms[2], parms[3]);
+       snprintf(pattern, sizeof pattern, "%s%s", parms[2], parms[3]);
 
        if (strlen(parms[3])==0) {
                cprintf("* LIST (\\Noselect) \"|\" \"\"\r\n");
@@ -592,7 +592,7 @@ void imap_list(int num_parms, char *parms[]) {
                cprintf("%s BAD arguments invalid\r\n", parms[0]);
                return;
        }
-       sprintf(pattern, "%s%s", parms[2], parms[3]);
+       snprintf(pattern, sizeof pattern, "%s%s", parms[2], parms[3]);
 
        if (strlen(parms[3])==0) {
                cprintf("* LIST (\\Noselect) \"|\" \"\"\r\n");
index 164e890c9d9ecd75078c42785b279741f7e25326..67baa62a27e21f92f7a92750348e998b38180a10 100644 (file)
@@ -215,7 +215,8 @@ void write_network_map(void) {
                        serialized_map = reallok(serialized_map,
                                                (strlen(serialized_map)+SIZ) );
                        if (strlen(nmptr->nodename) > 0) {
-                               sprintf(&serialized_map[strlen(serialized_map)],
+                               snprintf(&serialized_map[strlen(serialized_map)],
+                                       SIZ,
                                        "%s|%ld|%s\n",
                                        nmptr->nodename,
                                        (long)nmptr->lastcontact,
@@ -424,15 +425,16 @@ void network_spool_msg(long msgnum, void *userdata) {
                                (long)instr_len);
                        abort();
                }
-               sprintf(instr,
+               snprintf(instr, instr_len,
                        "Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
                        "bounceto|postmaster@%s\n" ,
                        SPOOLMIME, msgnum, (long)time(NULL), config.c_fqdn );
        
                /* Generate delivery instructions for each recipient */
                for (nptr = sc->listrecps; nptr != NULL; nptr = nptr->next) {
-                       sprintf(&instr[strlen(instr)], "remote|%s|0||\n",
-                               nptr->name);
+                       size_t tmp = strlen(instr);
+                       snprintf(&instr[tmp], instr_len - tmp,
+                                "remote|%s|0||\n", nptr->name);
                }
        
                /*
@@ -458,6 +460,7 @@ void network_spool_msg(long msgnum, void *userdata) {
        
                msg = CtdlFetchMessage(msgnum);
                if (msg != NULL) {
+                       size_t newpath_len;
 
                        /* Prepend our node name to the Path field whenever
                         * sending a message to another IGnet node
@@ -465,10 +468,11 @@ void network_spool_msg(long msgnum, void *userdata) {
                        if (msg->cm_fields['P'] == NULL) {
                                msg->cm_fields['P'] = strdoop("username");
                        }
-                       newpath = mallok(strlen(msg->cm_fields['P']) + 
-                                       strlen(config.c_nodename) + 2);
-                       sprintf(newpath, "%s!%s", config.c_nodename,
-                                       msg->cm_fields['P']);
+                       newpath_len = strlen(msg->cm_fields['P']) +
+                                strlen(config.c_nodename) + 2;
+                       newpath = mallok(newpath_len);
+                       snprintf(newpath, newpath_len, "%s!%s",
+                                config.c_nodename, msg->cm_fields['P']);
                        phree(msg->cm_fields['P']);
                        msg->cm_fields['P'] = newpath;
 
@@ -523,7 +527,7 @@ void network_spool_msg(long msgnum, void *userdata) {
 
                                /* Send the message */
                                if (send == 1) {
-                                       sprintf(filename,
+                                       snprintf(filename, sizeof filename,
                                                "./network/spoolout/%s",
                                                nptr->name);
                                        fp = fopen(filename, "ab");
@@ -705,12 +709,13 @@ void network_bounce(struct CtdlMessage *msg, char *reason) {
        struct recptypes *valid = NULL;
        char force_room[ROOMNAMELEN];
        static int serialnum = 0;
+       size_t size;
 
        lprintf(9, "entering network_bounce()\n");
 
        if (msg == NULL) return;
 
-       sprintf(bouncesource, "%s@%s", BOUNCESOURCE, config.c_nodename);
+       snprintf(bouncesource, sizeof bouncesource, "%s@%s", BOUNCESOURCE, config.c_nodename);
 
        /* 
         * Give it a fresh message ID
@@ -718,7 +723,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason) {
        if (msg->cm_fields['I'] != NULL) {
                phree(msg->cm_fields['I']);
        }
-       sprintf(buf, "%ld.%04lx.%04x@%s",
+       snprintf(buf, sizeof buf, "%ld.%04lx.%04x@%s",
                (long)time(NULL), (long)getpid(), ++serialnum, config.c_fqdn);
        msg->cm_fields['I'] = strdoop(buf);
 
@@ -766,8 +771,9 @@ void network_bounce(struct CtdlMessage *msg, char *reason) {
        else {
                oldpath = strdoop("unknown_user");
        }
-       msg->cm_fields['P'] = mallok(strlen(oldpath) + SIZ);
-       sprintf(msg->cm_fields['P'], "%s!%s", config.c_nodename, oldpath);
+       size = strlen(oldpath) + SIZ;
+       msg->cm_fields['P'] = mallok(size);
+       snprintf(msg->cm_fields['P'], size, "%s!%s", config.c_nodename, oldpath);
        phree(oldpath);
 
        /* Now submit the message */
@@ -844,9 +850,9 @@ void network_process_buffer(char *buffer, long size) {
                                else {
                                        oldpath = strdoop("unknown_user");
                                }
-                               msg->cm_fields['P'] =
-                                       mallok(strlen(oldpath) + SIZ);
-                               sprintf(msg->cm_fields['P'], "%s!%s",
+                               size = strlen(oldpath) + SIZ;
+                               msg->cm_fields['P'] = mallok(size);
+                               snprintf(msg->cm_fields['P'], size, "%s!%s",
                                        config.c_nodename, oldpath);
                                phree(oldpath);
 
@@ -854,7 +860,7 @@ void network_process_buffer(char *buffer, long size) {
                                serialize_message(&sermsg, msg);
 
                                /* now send it */
-                               sprintf(filename,
+                               snprintf(filename, sizeof filename,
                                        "./network/spoolout/%s",
                                        msg->cm_fields['D']);
                                fp = fopen(filename, "ab");
@@ -884,7 +890,7 @@ void network_process_buffer(char *buffer, long size) {
         * Check to see if we already have a copy of this message
         */
        if (network_usetable(msg) != 0) {
-               sprintf(buf,
+               snprintf(buf, sizeof buf,
                        "Loopzapper rejected message <%s> "
                        "from <%s> in <%s> @ <%s>\n",
                        ((msg->cm_fields['I']!=NULL)?(msg->cm_fields['I']):""),
@@ -1027,7 +1033,7 @@ void network_do_spoolin(void) {
        if (dp == NULL) return;
 
        while (d = readdir(dp), d != NULL) {
-               sprintf(filename, "./network/spoolin/%s", d->d_name);
+               snprintf(filename, sizeof filename, "./network/spoolin/%s", d->d_name);
                network_process_file(filename);
        }
 
@@ -1069,7 +1075,7 @@ void receive_spool(int sock, char *remote_nodename) {
        }
 
        while (bytes_received < download_len) {
-               sprintf(buf, "READ %ld|%ld",
+               snprintf(buf, sizeof buf, "READ %ld|%ld",
                        bytes_received,
                     ((download_len - bytes_received > IGNET_PACKET_SIZE)
                 ? IGNET_PACKET_SIZE : (download_len - bytes_received)));
@@ -1105,7 +1111,7 @@ void receive_spool(int sock, char *remote_nodename) {
                return;
        }
        lprintf(9, "%s\n", buf);
-       sprintf(buf, "mv %s ./network/spoolin/%s.%ld",
+       snprintf(buf, sizeof buf, "mv %s ./network/spoolin/%s.%ld",
                tempfilename, remote_nodename, (long) getpid());
        system(buf);
 }
@@ -1131,7 +1137,7 @@ void transmit_spool(int sock, char *remote_nodename)
                return;
        }
 
-       sprintf(sfname, "./network/spoolout/%s", remote_nodename);
+       snprintf(sfname, sizeof sfname, "./network/spoolout/%s", remote_nodename);
        fd = open(sfname, O_RDONLY);
        if (fd < 0) {
                if (errno == ENOENT) {
@@ -1145,7 +1151,7 @@ void transmit_spool(int sock, char *remote_nodename)
        while (plen = (long) read(fd, pbuf, IGNET_PACKET_SIZE), plen > 0L) {
                bytes_to_write = plen;
                while (bytes_to_write > 0L) {
-                       sprintf(buf, "WRIT %ld", bytes_to_write);
+                       snprintf(buf, sizeof buf, "WRIT %ld", bytes_to_write);
                        if (sock_puts(sock, buf) < 0) {
                                close(fd);
                                return;
@@ -1205,7 +1211,7 @@ void network_poll_node(char *node, char *secret, char *host, char *port) {
        lprintf(9, ">%s\n", buf);
 
        /* Identify ourselves */
-       sprintf(buf, "NETP %s|%s", config.c_nodename, secret);
+       snprintf(buf, sizeof buf, "NETP %s|%s", config.c_nodename, secret);
        lprintf(9, "<%s\n", buf);
        if (sock_puts(sock, buf) <0) goto bail;
        if (sock_gets(sock, buf) < 0) goto bail;
index 048459a27679b286d988a122b012b4f11e6af65d..92a02c12b23864b88e56e3583bd790ccef072cc2 100644 (file)
@@ -450,7 +450,7 @@ void pop3_update(void) {
                lgetuser(&CC->usersupp, CC->curr_user);
 
                CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
-               sprintf(vbuf.v_seen, "*:%ld",
+               snprintf(vbuf.v_seen, sizeof vbuf.v_seen, "*:%ld",
                        POP3->msgs[POP3->num_msgs-1].msgnum);
                CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
 
index 25082d77c12e04fca656e6bedf7f3a17de98c94c..7334ca0fbe406986f67d6245b812affd01c13187 100644 (file)
@@ -110,8 +110,8 @@ void smtp_greeting(void) {
        CtdlAllocUserData(SYM_SMTP, sizeof(struct citsmtp));
        CtdlAllocUserData(SYM_SMTP_RECPS, SIZ);
        CtdlAllocUserData(SYM_SMTP_ROOMS, SIZ);
-       sprintf(SMTP_RECPS, "%s", "");
-       sprintf(SMTP_ROOMS, "%s", "");
+       snprintf(SMTP_RECPS, SIZ, "%s", "");
+       snprintf(SMTP_ROOMS, SIZ, "%s", "");
 
        cprintf("220 %s ESMTP Citadel/UX server ready.\r\n", config.c_fqdn);
 }
@@ -620,7 +620,8 @@ void smtp_command_loop(void) {
  * Called by smtp_do_procmsg() to attempt delivery to one SMTP host
  *
  */
-void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum)
+void smtp_try(const char *key, const char *addr, int *status,
+             char *dsn, size_t n, long msgnum)
 {
        int sock = (-1);
        char mxhosts[1024];
@@ -646,7 +647,7 @@ void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum)
        msg_fp = tmpfile();
        if (msg_fp == NULL) {
                *status = 4;
-               sprintf(dsn, "Error creating temporary file");
+               snprintf(dsn, n, "Error creating temporary file");
                return;
        }
        else {
@@ -1197,7 +1198,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
                        --i;
                        --lines;
                        lprintf(9, "SMTP: Trying <%s>\n", addr);
-                       smtp_try(key, addr, &status, dsn, text_msgid);
+                       smtp_try(key, addr, &status, dsn, sizeof dsn, text_msgid);
                        if (status != 2) {
                                if (results == NULL) {
                                        results = mallok(1024);
@@ -1207,7 +1208,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
                                        results = reallok(results,
                                                strlen(results) + 1024);
                                }
-                               sprintf(&results[strlen(results)],
+                               snprintf(&results[strlen(results)], 1024,
                                        "%s|%s|%d|%s\n",
                                        key, addr, status, dsn);
                        }
index bc330df66e4f70c5147ed166f646c7acc38ba3fc..c7b73329c1dd59659502e25e9912886beb6e8f20 100644 (file)
@@ -70,6 +70,7 @@ int main(int argc, char **argv)
        int drop_root_perms = 1;
        char *moddir;
        struct worker_node *wnp;
+       size_t size;
         
        /* specify default port name and trace file */
        strcpy(tracefile, "");
@@ -170,8 +171,9 @@ int main(int argc, char **argv)
         * Load any server-side modules (plugins) available here.
         */
        lprintf(7, "Initializing loadable modules\n");
-       if ((moddir = malloc(strlen(bbs_home_directory) + 9)) != NULL) {
-               sprintf(moddir, "%s/modules", bbs_home_directory);
+       size = strlen(bbs_home_directory) + 9;
+       if ((moddir = mallok(size)) != NULL) {
+               snprintf(moddir, size, "%s/modules", bbs_home_directory);
                DLoader_Init(moddir);
                free(moddir);
        }
index bb7e2a9ed9fb38fb346fcdb99849c159fabefbb6..493e90b2ece55e923fce1bd6bbbc55087cd316e9 100644 (file)
@@ -340,7 +340,7 @@ void striplt(char *buf)
 /* 
  * Return the number of occurances of character ch in string st
  */ 
-int haschar(char *st, int ch)
+int haschar(const char *st, int ch)
 {
        int a, b;
        b = 0;
index 36532f40896149b0ae05fff048db4ac33d4bcd5b..57d03d89caa03b3048c3c140fd5abfdbbfe0092c 100644 (file)
@@ -7,7 +7,7 @@ long int extract_long (char *source, long int parmnum);
 void encode_base64(char *dest, char *source);
 int decode_base64(char *dest, char *source, size_t length);
 void striplt(char *);
-int haschar(char *st, int ch);
+int haschar(const char *st, int ch);
 int collapsed_strcmp(char *s1, char *s2);
 void remove_token(char *source, int parmnum, char separator);
 void fmt_date(char *buf, time_t thetime, int seconds);