]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Changed most of sprintf() to snprintf().
authorkostas <>
Tue, 14 Oct 1997 04:09:03 +0000 (04:09 +0000)
committerkostas <>
Tue, 14 Oct 1997 04:09:03 +0000 (04:09 +0000)
29 files changed:
src/cache_cf.cc
src/cachemgr.cc
src/client.cc
src/client_side.cc
src/debug.cc
src/dns.cc
src/dnsserver.cc
src/errorpage.cc
src/fqdncache.cc
src/ftp.cc
src/gopher.cc
src/http.cc
src/icmp.cc
src/ident.cc
src/ipcache.cc
src/mime.cc
src/neighbors.cc
src/net_db.cc
src/redirect.cc
src/send-announce.cc
src/ssl.cc
src/stat.cc
src/store.cc
src/store_dir.cc
src/tools.cc
src/tunnel.cc
src/url.cc
src/useragent.cc
src/wais.cc

index d77eb77532dc2242c56e988f1008c612603a8da2..d3690fa505cc5d1eda3d31b9280ded2180347cb3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cache_cf.cc,v 1.223 1997/08/25 22:35:50 wessels Exp $
+ * $Id: cache_cf.cc,v 1.224 1997/10/13 22:09:03 kostas Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -70,7 +70,7 @@ static void free_all _PARAMS((void));
 static void
 self_destruct(void)
 {
-    sprintf(fatal_str, "Bungled %s line %d: %s",
+    snprintf(fatal_str,BUFSIZ, "Bungled %s line %d: %s",
        cfg_filename, config_lineno, config_input_line);
     fatal(fatal_str);
 }
@@ -144,7 +144,7 @@ parseConfigFile(const char *file_name)
     free_all();
     default_all();
     if ((fp = fopen(file_name, "r")) == NULL) {
-       sprintf(fatal_str, "Unable to open configuration file: %s: %s",
+       snprintf(fatal_str, BUFSIZ, "Unable to open configuration file: %s: %s",
            file_name, xstrerror());
        fatal(fatal_str);
     }
@@ -232,7 +232,7 @@ configDoConfigure(void)
        vhost_mode = 1;
     if (Config.Port.http == NULL)
        fatal("No http_port specified!");
-    sprintf(ThisCache, "%s:%d (Squid/%s)",
+    snprintf(ThisCache, SQUIDHOSTNAMELEN << 1, "%s:%d (Squid/%s)",
        getMyHostname(),
        (int) Config.Port.http->i,
        SQUID_VERSION);
index 1932b8224c28eb3de41ea2d8e91ae22132705a17..f112b6b5a8f19c471f1afa89cca52b3851afed61 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cachemgr.cc,v 1.60 1997/08/26 17:30:35 wessels Exp $
+ * $Id: cachemgr.cc,v 1.61 1997/10/13 22:09:04 kostas Exp $
  *
  * DEBUG: section 0     CGI Cache Manager
  * AUTHOR: Harvest Derived
 
 #include "ansiproto.h"
 #include "util.h"
+#include "snprintf.h"
 
 #define MAX_ENTRIES 10000
 
@@ -506,20 +507,20 @@ describeTimeSince(time_t then)
     if (then < 0)
        return "NEVER";
     if (delta < ONE_MINUTE)
-       sprintf(buf, "%ds", (int) (delta / ONE_SECOND));
+       snprintf(buf, 128, "%ds", (int) (delta / ONE_SECOND));
     else if (delta < ONE_HOUR)
-       sprintf(buf, "%dm", (int) (delta / ONE_MINUTE));
+       snprintf(buf, 128, "%dm", (int) (delta / ONE_MINUTE));
     else if (delta < ONE_DAY)
-       sprintf(buf, "%dh", (int) (delta / ONE_HOUR));
+       snprintf(buf, 128, "%dh", (int) (delta / ONE_HOUR));
     else if (delta < ONE_WEEK)
-       sprintf(buf, "%dD", (int) (delta / ONE_DAY));
+       snprintf(buf, 128, "%dD", (int) (delta / ONE_DAY));
     else if (delta < ONE_MONTH)
-       sprintf(buf, "%dW", (int) (delta / ONE_WEEK));
+       snprintf(buf, 128, "%dW", (int) (delta / ONE_WEEK));
     else if (delta < ONE_YEAR)
-       sprintf(buf, "%dM", (int) (delta / ONE_MONTH));
+       snprintf(buf, 128, "%dM", (int) (delta / ONE_MONTH));
     else
-       sprintf(buf, "%dY", (int) (delta / ONE_YEAR));
-    sprintf(buf2, fmt, buf);
+       snprintf(buf, 128, "%dY", (int) (delta / ONE_YEAR));
+    snprintf(buf2,128, fmt, buf);
     return buf2;
 }
 
@@ -656,15 +657,16 @@ main(int argc, char *argv[])
        /* convert hostname:portnum to host=hostname&port=portnum */
        if (*s && !strchr(s, '=') && !strchr(s, '&')) {
            char *p;
-           buffer = xmalloc(strlen(s) + sizeof "host=&port=");
+            int len_buff=strlen(s) + sizeof "host=&port=";
+           buffer = xmalloc(len_buff);
            if ((p = strchr(s, ':')))
                if (p != s) {
                    *p = '\0';
-                   sprintf(buffer, "host=%s&port=%s", s, p + 1);
+                   snprintf(buffer, len_buff,"host=%s&port=%s", s, p + 1);
                } else {
-                   sprintf(buffer, "port=%s", p + 1);
+                   snprintf(buffer, len_buff, "port=%s", p + 1);
            } else
-               sprintf(buffer, "host=%s", s);
+               snprintf(buffer, len_buff, "host=%s", s);
        } else {
            buffer = xstrdup(s);
        }
@@ -749,11 +751,11 @@ main(int argc, char *argv[])
     case STATS_NETDB:
     case PCONN:
     case SHUTDOWN:
-       sprintf(msg, "GET cache_object://%s/%s@%s HTTP/1.0\r\n\r\n",
+       snprintf(msg, 1024, "GET cache_object://%s/%s@%s HTTP/1.0\r\n\r\n",
            hostname, op_cmds[op], password);
        break;
     case REFRESH:
-       sprintf(msg, "GET %s HTTP/1.0\r\nPragma: no-cache\r\nAccept: */*\r\n\r\n", url);
+       snprintf(msg, 1024, "GET %s HTTP/1.0\r\nPragma: no-cache\r\nAccept: */*\r\n\r\n", url);
        break;
 #ifdef REMOVE_OBJECT
     case REMOVE:
index 0f9692810a39a9bd16dfaeb9452ddda177a427ab..9dd057300293c5f07c57328306ccd65cb71a10db 100644 (file)
@@ -1,7 +1,7 @@
 
 
 /*
- * $Id: client.cc,v 1.29 1997/08/25 23:45:24 wessels Exp $
+ * $Id: client.cc,v 1.30 1997/10/13 22:09:05 kostas Exp $
  *
  * DEBUG: section 0     WWW Client
  * AUTHOR: Harvest Derived
@@ -207,35 +207,35 @@ main(int argc, char *argv[])
            fprintf(stderr, "client: ERROR: Cannot connect to %s:%d: Host unknown.\n", hostname, port);
        } else {
            char tbuf[BUFSIZ];
-           sprintf(tbuf, "client: ERROR: Cannot connect to %s:%d",
+           snprintf(tbuf, BUFSIZ, "client: ERROR: Cannot connect to %s:%d",
                hostname, port);
            perror(tbuf);
        }
        exit(1);
     }
     /* Build the HTTP request */
-    sprintf(msg, "%s %s HTTP/1.0\r\n", method, url);
+    snprintf(msg, BUFSIZ, "%s %s HTTP/1.0\r\n", method, url);
     if (reload) {
-       sprintf(buf, "Pragma: no-cache\r\n");
+       snprintf(buf, BUFSIZ, "Pragma: no-cache\r\n");
        strcat(msg, buf);
     }
     if (opt_noaccept == 0) {
-       sprintf(buf, "Accept: */*\r\n");
+       snprintf(buf, BUFSIZ, "Accept: */*\r\n");
        strcat(msg, buf);
     }
     if (ims) {
-       sprintf(buf, "If-Modified-Since: %s\r\n", mkrfc1123(ims));
+       snprintf(buf, BUFSIZ, "If-Modified-Since: %s\r\n", mkrfc1123(ims));
        strcat(msg, buf);
     }
     if (max_forwards > -1) {
-       sprintf(buf, "Max-Forwards: %d\r\n", max_forwards);
+       snprintf(buf, BUFSIZ, "Max-Forwards: %d\r\n", max_forwards);
        strcat(msg, buf);
     }
     if (keep_alive) {
-       sprintf(buf, "Proxy-Connection: Keep-Alive\r\n");
+       snprintf(buf, BUFSIZ, "Proxy-Connection: Keep-Alive\r\n");
        strcat(msg, buf);
     }
-    sprintf(buf, "\r\n");
+    snprintf(buf, BUFSIZ, "\r\n");
     strcat(msg, buf);
 
     /* Send the HTTP request */
index ea8c8e29fa341c1f96ee50a8c7ec2aebace0405e..c1b4a5cfb11cffd5263af7597a9049b398888a88 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.125 1997/08/25 23:45:25 wessels Exp $
+ * $Id: client_side.cc,v 1.126 1997/10/13 22:09:05 kostas Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -332,12 +332,12 @@ clientConstructTraceEcho(clientHttpRequest * http)
     LOCAL_ARRAY(char, buf, 8192);
     size_t len;
     memset(buf, '\0', 8192);
-    sprintf(buf, "HTTP/1.0 200 OK\r\n");
-    sprintf(line, "Date: %s\r\n", mkrfc1123(squid_curtime));
+    snprintf(buf, 8192, "HTTP/1.0 200 OK\r\n");
+    snprintf(line, 256,  "Date: %s\r\n", mkrfc1123(squid_curtime));
     strcat(buf, line);
-    sprintf(line, "Server: Squid/%s\r\n", SQUID_VERSION);
+    snprintf(line, 256, "Server: Squid/%s\r\n", SQUID_VERSION);
     strcat(buf, line);
-    sprintf(line, "Content-Type: message/http\r\n");
+    snprintf(line, 256, "Content-Type: message/http\r\n");
     strcat(buf, line);
     strcat(buf, "\r\n");
     len = strlen(buf);
index e75ff6e4b03bca502be26a3af190712b4ebf7c2d..e9d5b5a0733df0dcdf65fd8d94862cc55c61c4ef 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: debug.cc,v 1.51 1997/07/26 04:48:27 wessels Exp $
+ * $Id: debug.cc,v 1.52 1997/10/13 22:09:06 kostas Exp $
  *
  * DEBUG: section 0     Debug Routines
  * AUTHOR: Harvest Derived
@@ -135,14 +135,14 @@ _db_print(va_alist)
 
     if (debug_log == NULL)
        return;
-    sprintf(f, "%s| %s",
+    snprintf(f, BUFSIZ, "%s| %s",
        accessLogTime(squid_curtime),
        format);
 #if HAVE_SYSLOG
     /* level 0 go to syslog */
     if (_db_level == 0 && opt_syslog_enable) {
        tmpbuf[0] = '\0';
-       vsprintf(tmpbuf, format, args);
+       vsnprintf(tmpbuf, BUFSIZ, format, args);
        tmpbuf[1023] = '\0';
        syslog(LOG_ERR, "%s", tmpbuf);
     }
@@ -248,13 +248,13 @@ _db_rotate_log(void)
     /* Rotate numbers 0 through N up one */
     for (i = Config.Log.rotateNumber; i > 1;) {
        i--;
-       sprintf(from, "%s.%d", debug_log_file, i - 1);
-       sprintf(to, "%s.%d", debug_log_file, i);
+       snprintf(from, MAXPATHLEN, "%s.%d", debug_log_file, i - 1);
+       snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, i);
        rename(from, to);
     }
     /* Rotate the current log to .0 */
     if (Config.Log.rotateNumber > 0) {
-       sprintf(to, "%s.%d", debug_log_file, 0);
+       snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, 0);
        rename(debug_log_file, to);
     }
     /* Close and reopen the log.  It may have been renamed "manually"
index 41c5d3e68b658dd80a2e7d567feda7d601fd6980..f40452f96dddf49e87137e128af87b9cca210e1b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: dns.cc,v 1.40 1997/08/10 06:34:28 wessels Exp $
+ * $Id: dns.cc,v 1.41 1997/10/13 22:09:06 kostas Exp $
  *
  * DEBUG: section 34    Dnsserver interface
  * AUTHOR: Harvest Derived
@@ -276,7 +276,7 @@ dnsOpenServers(void)
                s++;
            else
                s = prg;
-           sprintf(fd_note_buf, "%s #%d", s, dns_child_table[k]->id);
+           snprintf(fd_note_buf,FD_DESC_SZ, "%s #%d", s, dns_child_table[k]->id);
            fd_note(dns_child_table[k]->inpipe, fd_note_buf);
            commSetNonBlocking(dns_child_table[k]->inpipe);
            debug(34, 3) ("dnsOpenServers: 'dns_server' %d started\n", k);
index 5048fc47197cf08de67ca16570223b30e877bee8..2a663cb72fa47f5f42a7b98c08a3cbd109dfdd20 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: dnsserver.cc,v 1.34 1997/07/16 20:32:03 wessels Exp $
+ * $Id: dnsserver.cc,v 1.35 1997/10/13 22:09:07 kostas Exp $
  *
  * DEBUG: section 0     DNS Resolver
  * AUTHOR: Harvest Derived
@@ -284,7 +284,7 @@ main(int argc, char *argv[])
            exit(0);
            break;
        case 'd':
-           sprintf(buf, "dnsserver.%d.log", (int) getpid());
+           snprintf(buf, 256, "dnsserver.%d.log", (int) getpid());
            logfile = fopen(buf, "a");
            do_debug++;
            if (!logfile)
@@ -364,10 +364,10 @@ main(int argc, char *argv[])
        msg[0] = '\0';
        if (!result) {
            if (h_errno == TRY_AGAIN) {
-               sprintf(msg, "Name Server for domain '%s' is unavailable.\n",
+               snprintf(msg, 1024,  "Name Server for domain '%s' is unavailable.\n",
                    request);
            } else {
-               sprintf(msg, "DNS Domain '%s' is invalid: %s.\n",
+               snprintf(msg, 1024, "DNS Domain '%s' is invalid: %s.\n",
                    request, my_h_msgs(h_errno));
            }
        }
index 72ca7dbb2343d445d0b144b4af95ed0bce864fa7..6ab532074116eea8eef734eb93e6e303965a4315 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.cc,v 1.69 1997/08/25 22:35:54 wessels Exp $
+ * $Id: errorpage.cc,v 1.70 1997/10/13 22:09:08 kostas Exp $
  *
  * DEBUG: section 4     Error Generation
  * AUTHOR: Duane Wessels
@@ -131,9 +131,16 @@ errorConvert(char token, ErrorState * err)
     case 'z':
        p = err->dnsserver_msg;
        break;
+    case 'e':
+       snprintf(buf, CVT_BUF_SZ, "%d", err->errno);
+       p=buf;
+       break;
+    case 'E':
+       snprintf(buf, CVT_BUF_SZ, "(%d) %s", err->errno, xstrerror());
+       break;
 /*
- * e - errno
- * E - strerror()
+ * e - errno                                   x
+ * E - strerror()                              x
  * t - local time
  * T - UTC
  * c - Squid error code
index 83e8c54a8b14d0b1850127aa55274ef54fd5267c..e909ec8f6c99d1758d62cc7225d8223b80d59e54 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fqdncache.cc,v 1.59 1997/08/25 23:45:26 wessels Exp $
+ * $Id: fqdncache.cc,v 1.60 1997/10/13 22:09:08 kostas Exp $
  *
  * DEBUG: section 35    FQDN Cache
  * AUTHOR: Harvest Derived
@@ -693,7 +693,7 @@ fqdncache_dnsDispatch(dnsserver_t * dns, fqdncache_entry * f)
     if (f->status != FQDN_PENDING)
        debug_trap("fqdncache_dnsDispatch: status != FQDN_PENDING");
     buf = xcalloc(1, 256);
-    sprintf(buf, "%1.254s\n", f->name);
+    snprintf(buf, 256, "%1.254s\n", f->name);
     dns->flags |= DNS_FLAG_BUSY;
     dns->data = f;
     f->status = FQDN_DISPATCHED;
@@ -994,7 +994,7 @@ fqdncacheChangeKey(fqdncache_entry * f)
        debug_trap("fqdncacheChangeKey: hash_remove_link() failed\n");
        return;
     }
-    sprintf(new_key, "%d/", ++index);
+    snprintf(new_key, 256, "%d/", ++index);
     strncat(new_key, f->name, 128);
     debug(14, 1) ("fqdncacheChangeKey: from '%s' to '%s'\n", f->name, new_key);
     safe_free(f->name);
index e96be84ecdef98dee3272e554771ba3ca51952ea..b92c4e4fbcf21e667706cfae89972b508dff7a8b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.136 1997/07/28 06:40:55 wessels Exp $
+ * $Id: ftp.cc,v 1.137 1997/10/13 22:09:09 kostas Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -360,10 +360,10 @@ ftpListParseParts(const char *buf, int flags)
            continue;
        p->type = *tokens[0];
        p->size = atoi(tokens[i - 1]);
-       sprintf(sbuf, "%s %2s %5s",
+       snprintf(sbuf, 128, "%s %2s %5s",
            tokens[i], tokens[i + 1], tokens[i + 2]);
        if (!strstr(buf, sbuf))
-           sprintf(sbuf, "%s %2s %-5s",
+           snprintf(sbuf, 128, "%s %2s %-5s",
                tokens[i], tokens[i + 1], tokens[i + 2]);
        if ((t = strstr(buf, sbuf))) {
            p->date = xstrdup(sbuf);
@@ -397,7 +397,7 @@ ftpListParseParts(const char *buf, int flags)
            p->type = '-';
            p->size = atoi(tokens[2]);
        }
-       sprintf(sbuf, "%s %s", tokens[0], tokens[1]);
+       snprintf(sbuf, 128, "%s %s", tokens[0], tokens[1]);
        p->date = xstrdup(sbuf);
        p->name = xstrdup(tokens[3]);
     }
@@ -474,20 +474,20 @@ ftpHtmlifyListEntry(char *line, int flags)
     ftpListParts *parts;
     /* check .. as special case */
     if (!strcmp(line, "..")) {
-       sprintf(icon, "<IMG BORDER=0 SRC=\"%s%s\" ALT=\"%-6s\">",
+       snprintf(icon, 2048, "<IMG BORDER=0 SRC=\"%s%s\" ALT=\"%-6s\">",
            "http://internal.squid/icons/",
            ICON_DIRUP,
            "[DIR]");
-       sprintf(link, "<A HREF=\"%s\">%s</A>", "../", "Parent Directory");
-       sprintf(html, "%s %s\n", icon, link);
+       snprintf(link, 2048,  "<A HREF=\"%s\">%s</A>", "../", "Parent Directory");
+       snprintf(html, 8192, "%s %s\n", icon, link);
        return html;
     }
     if (strlen(line) > 1024) {
-       sprintf(html, "%s\n", line);
+       snprintf(html, 8192, "%s\n", line);
        return html;
     }
     if ((parts = ftpListParseParts(line, flags)) == NULL) {
-       sprintf(html, "%s\n", line);
+       snprintf(html, 8192, "%s\n", line);
        return html;
     }
     if (!strcmp(parts->name, ".") || !strcmp(parts->name, "..")) {
@@ -507,44 +507,44 @@ ftpHtmlifyListEntry(char *line, int flags)
     ename = xstrdup(rfc1738_escape(parts->name));
     switch (parts->type) {
     case 'd':
-       sprintf(icon, "<IMG SRC=\"%s%s\" ALT=\"%-6s\">",
+       snprintf(icon, 2048, "<IMG SRC=\"%s%s\" ALT=\"%-6s\">",
            "http://internal.squid/icons/",
            ICON_MENU,
            "[DIR]");
-       sprintf(link, "<A HREF=\"%s/\">%s</A>%s",
+       snprintf(link, 2048,  "<A HREF=\"%s/\">%s</A>%s",
            ename,
            parts->showname,
            dots_fill(strlen(parts->showname)));
-       sprintf(html, "%s %s  [%s]\n",
+       snprintf(html, 8192, "%s %s  [%s]\n",
            icon,
            link,
            parts->date);
        break;
     case 'l':
-       sprintf(icon, "<IMG SRC=\"%s%s\" ALT=\"%-6s\">",
+       snprintf(icon, 2048,  "<IMG SRC=\"%s%s\" ALT=\"%-6s\">",
            "http://internal.squid/icons/",
            ICON_LINK,
            "[LINK]");
-       sprintf(link, "<A HREF=\"%s\">%s</A>%s",
+       snprintf(link, 2048, "<A HREF=\"%s\">%s</A>%s",
            ename,
            parts->showname,
            dots_fill(strlen(parts->showname)));
-       sprintf(html, "%s %s  [%s]\n",
+       snprintf(html, 8192, "%s %s  [%s]\n",
            icon,
            link,
            parts->date);
        break;
     case '-':
     default:
-       sprintf(icon, "<IMG SRC=\"%s%s\" ALT=\"%-6s\">",
+       snprintf(icon, 2048,  "<IMG SRC=\"%s%s\" ALT=\"%-6s\">",
            "http://internal.squid/icons/",
            mimeGetIcon(parts->name),
            "[FILE]");
-       sprintf(link, "<A HREF=\"%s\">%s</A>%s",
+       snprintf(link, 2048, "<A HREF=\"%s\">%s</A>%s",
            ename,
            parts->showname,
            dots_fill(strlen(parts->showname)));
-       sprintf(html, "%s %s  [%s] %6dk\n",
+       snprintf(html, 8192, "%s %s  [%s] %6dk\n",
            icon,
            link,
            parts->date,
@@ -830,7 +830,7 @@ ftpBuildTitleUrl(FtpStateData * ftpState)
     }
     strcat(t, request->host);
     if (request->port != urlDefaultPort(PROTO_FTP))
-       sprintf(&t[strlen(t)], ":%d", request->port);
+       snprintf(&t[strlen(t)], len-strlen(t), ":%d", request->port);
     strcat(t, "/");
     if (!EBIT_TEST(ftpState->flags, FTP_ROOT_DIR))
        strcat(t, request->urlpath);
@@ -858,9 +858,9 @@ ftpStart(request_t * request, StoreEntry * entry)
     if (!ftpCheckAuth(ftpState, request->headers)) {
        /* This request is not fully authenticated */
        if (request->port == 21) {
-           sprintf(realm, "ftp %s", ftpState->user);
+           snprintf(realm,8192, "ftp %s", ftpState->user);
        } else {
-           sprintf(realm, "ftp %s port %d",
+           snprintf(realm,8192, "ftp %s port %d",
                ftpState->user, request->port);
        }
        response = ftpAuthRequired(request, realm);
@@ -1120,11 +1120,11 @@ ftpReadWelcome(FtpStateData * ftpState)
            if (strstr(ftpState->ctrl.message->key, "NetWare"))
                EBIT_SET(ftpState->flags, FTP_SKIP_WHITESPACE);
        if (ftpState->proxy_host != NULL)
-           sprintf(cbuf, "USER %s@%s\r\n",
+           snprintf(cbuf,1024, "USER %s@%s\r\n",
                ftpState->user,
                ftpState->request->host);
        else
-           sprintf(cbuf, "USER %s\r\n", ftpState->user);
+           snprintf(cbuf,1024, "USER %s\r\n", ftpState->user);
        ftpWriteCommand(cbuf, ftpState);
        ftpState->state = SENT_USER;
     } else {
@@ -1140,7 +1140,7 @@ ftpReadUser(FtpStateData * ftpState)
     if (code == 230) {
        ftpReadPass(ftpState);
     } else if (code == 331) {
-       sprintf(cbuf, "PASS %s\r\n", ftpState->password);
+       snprintf(cbuf,1024, "PASS %s\r\n", ftpState->password);
        ftpWriteCommand(cbuf, ftpState);
        ftpState->state = SENT_PASS;
     } else {
@@ -1160,7 +1160,7 @@ ftpReadPass(FtpStateData * ftpState)
        t = strrchr(ftpState->request->urlpath, '/');
        filename = t ? t + 1 : ftpState->request->urlpath;
        mode = mimeGetTransferMode(filename);
-       sprintf(cbuf, "TYPE %c\r\n", mode);
+       snprintf(cbuf,1024, "TYPE %c\r\n", mode);
        ftpWriteCommand(cbuf, ftpState);
        ftpState->state = SENT_TYPE;
     } else {
@@ -1211,7 +1211,7 @@ ftpSendCwd(FtpStateData * ftpState)
        ftpSendPasv(ftpState);
        return;
     }
-    sprintf(cbuf, "CWD %s\r\n", w->key);
+    snprintf(cbuf, 1024, "CWD %s\r\n", w->key);
     ftpWriteCommand(cbuf, ftpState);
     ftpState->state = SENT_CWD;
 }
@@ -1249,7 +1249,7 @@ ftpReadCwd(FtpStateData * ftpState)
        }
        wordlistDestroy(&ftpState->pathcomps);
        assert(*ftpState->filepath != '\0');
-       sprintf(cbuf, "MDTM %s\r\n", ftpState->filepath);
+       snprintf(cbuf, 1024, "MDTM %s\r\n", ftpState->filepath);
        ftpWriteCommand(cbuf, ftpState);
        ftpState->state = SENT_MDTM;
     }
@@ -1267,7 +1267,7 @@ ftpReadMdtm(FtpStateData * ftpState)
     }
     assert(ftpState->filepath != NULL);
     assert(*ftpState->filepath != '\0');
-    sprintf(cbuf, "SIZE %s\r\n", ftpState->filepath);
+    snprintf(cbuf, 1024, "SIZE %s\r\n", ftpState->filepath);
     ftpWriteCommand(cbuf, ftpState);
     ftpState->state = SENT_SIZE;
 }
@@ -1306,7 +1306,7 @@ ftpSendPasv(FtpStateData * ftpState)
     }
     ftpState->data.fd = fd;
     commSetTimeout(fd, Config.Timeout.read, ftpTimeout, ftpState);
-    sprintf(cbuf, "PASV\r\n");
+    snprintf(cbuf, 1024, "PASV\r\n");
     ftpWriteCommand(cbuf, ftpState);
     ftpState->state = SENT_PASV;
 }
@@ -1344,7 +1344,7 @@ ftpReadPasv(FtpStateData * ftpState)
        ftpSendPort(ftpState);
        return;
     }
-    sprintf(junk, "%d.%d.%d.%d", h1, h2, h3, h4);
+    snprintf(junk,1024, "%d.%d.%d.%d", h1, h2, h3, h4);
     if (!safe_inet_addr(junk, NULL)) {
        debug(9, 1) ("unsafe address (%s)\n", junk);
        ftpSendPort(ftpState);
@@ -1398,16 +1398,16 @@ ftpRestOrList(FtpStateData * ftpState)
 {
     debug(9, 3) ("This is ftpRestOrList\n");
     if (EBIT_TEST(ftpState->flags, FTP_ISDIR)) {
-       sprintf(cbuf, "LIST\r\n");
+       snprintf(cbuf, 1024, "LIST\r\n");
        ftpWriteCommand(cbuf, ftpState);
        ftpState->state = SENT_LIST;
     } else if (ftpState->restart_offset > 0) {
-       sprintf(cbuf, "REST\r\n");
+       snprintf(cbuf,1024, "REST\r\n");
        ftpWriteCommand(cbuf, ftpState);
        ftpState->state = SENT_REST;
     } else {
        assert(ftpState->filepath != NULL);
-       sprintf(cbuf, "RETR %s\r\n", ftpState->filepath);
+       snprintf(cbuf,1024, "RETR %s\r\n", ftpState->filepath);
        ftpWriteCommand(cbuf, ftpState);
        ftpState->state = SENT_RETR;
     }
@@ -1421,7 +1421,7 @@ ftpReadRest(FtpStateData * ftpState)
     assert(ftpState->restart_offset > 0);
     if (code == 350) {
        assert(ftpState->filepath != NULL);
-       sprintf(cbuf, "RETR %s\r\n", ftpState->filepath);
+       snprintf(cbuf,1024, "RETR %s\r\n", ftpState->filepath);
        ftpWriteCommand(cbuf, ftpState);
        ftpState->state = SENT_RETR;
     } else if (code > 0) {
@@ -1448,7 +1448,7 @@ ftpReadList(FtpStateData * ftpState)
        return;
     } else if (!EBIT_TEST(ftpState->flags, FTP_TRIED_NLST)) {
        EBIT_SET(ftpState->flags, FTP_TRIED_NLST);
-       sprintf(cbuf, "NLST\r\n");
+       snprintf(cbuf, 1024, "NLST\r\n");
        ftpWriteCommand(cbuf, ftpState);
        ftpState->state = SENT_NLST;
     } else {
@@ -1497,7 +1497,7 @@ ftpDataTransferDone(FtpStateData * ftpState)
        ftpState->data.fd = -1;
     }
     assert(ftpState->ctrl.fd > -1);
-    sprintf(cbuf, "QUIT\r\n");
+    snprintf(cbuf,1024, "QUIT\r\n");
     ftpWriteCommand(cbuf, ftpState);
     ftpState->state = SENT_QUIT;
 }
index 86f50484e9139a432f058aab24a2483de84108bf..18fa934a2b2f58e8d901f2f4593330cc0f493344 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: gopher.cc,v 1.92 1997/07/28 06:40:56 wessels Exp $
+ * $Id: gopher.cc,v 1.93 1997/10/13 22:09:10 kostas Exp $
  *
  * DEBUG: section 10    Gopher
  * AUTHOR: Harvest Derived
@@ -208,8 +208,8 @@ gopher_mime_content(char *buf, const char *name, const char *def_ctype)
     char *ctype = mimeGetContentType(name);
     char *cenc = mimeGetContentEncoding(name);
     if (cenc)
-       sprintf(buf + strlen(buf), "Content-Encoding: %s\r\n", cenc);
-    sprintf(buf + strlen(buf), "Content-Type: %s\r\n",
+       snprintf(buf + strlen(buf), MAX_MIME-strlen(buf), "Content-Encoding: %s\r\n", cenc);
+    snprintf(buf + strlen(buf), MAX_MIME-strlen(buf), "Content-Type: %s\r\n",
        ctype ? ctype : def_ctype);
 }
 
@@ -221,7 +221,7 @@ gopherMimeCreate(GopherStateData * gopherState)
 {
     LOCAL_ARRAY(char, tempMIME, MAX_MIME);
 
-    sprintf(tempMIME,
+    snprintf(tempMIME, MAX_MIME,
        "HTTP/1.0 200 OK Gatewaying\r\n"
        "Server: Squid/%s\r\n"
        "Date: %s\r\n"
@@ -332,7 +332,8 @@ gopherEndHTML(GopherStateData * gopherState)
     LOCAL_ARRAY(char, tmpbuf, TEMP_BUF_SIZE);
 
     if (!gopherState->data_in) {
-       sprintf(tmpbuf, "<HTML><HEAD><TITLE>Server Return Nothing.</TITLE>\n"
+       snprintf(tmpbuf, TEMP_BUF_SIZE,
+               "<HTML><HEAD><TITLE>Server Return Nothing.</TITLE>\n"
            "</HEAD><BODY><HR><H1>Server Return Nothing.</H1></BODY></HTML>\n");
        storeAppend(gopherState->entry, tmpbuf, strlen(tmpbuf));
        return;
@@ -367,7 +368,8 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
     entry = gopherState->entry;
 
     if (gopherState->conversion == HTML_INDEX_PAGE) {
-       sprintf(outbuf, "<HTML><HEAD><TITLE>Gopher Index %s</TITLE></HEAD>\n"
+       snprintf(outbuf, TEMP_BUF_SIZE << 4, 
+            "<HTML><HEAD><TITLE>Gopher Index %s</TITLE></HEAD>\n"
            "<BODY><H1>%s<BR>Gopher Search</H1>\n"
            "<p>This is a searchable Gopher index. Use the search\n"
            "function of your browser to enter search terms.\n"
@@ -380,7 +382,8 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
        return;
     }
     if (gopherState->conversion == HTML_CSO_PAGE) {
-       sprintf(outbuf, "<HTML><HEAD><TITLE>CSO Search of %s</TITLE></HEAD>\n"
+       snprintf(outbuf, TEMP_BUF_SIZE << 4, 
+            "<HTML><HEAD><TITLE>CSO Search of %s</TITLE></HEAD>\n"
            "<BODY><H1>%s<BR>CSO Search</H1>\n"
            "<P>A CSO database usually contains a phonebook or\n"
            "directory.  Use the search function of your browser to enter\n"
@@ -546,14 +549,14 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
                        memset(tmpbuf, '\0', TEMP_BUF_SIZE);
                        if ((gtype == GOPHER_TELNET) || (gtype == GOPHER_3270)) {
                            if (strlen(escaped_selector) != 0)
-                               sprintf(tmpbuf, "<IMG BORDER=0 SRC=\"%s\"> <A HREF=\"telnet://%s@%s/\">%s</A>\n",
+                               snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG BORDER=0 SRC=\"%s\"> <A HREF=\"telnet://%s@%s/\">%s</A>\n",
                                    icon_type, escaped_selector, host, name);
                            else
-                               sprintf(tmpbuf, "<IMG BORDER=0 SRC=\"%s\"> <A HREF=\"telnet://%s/\">%s</A>\n",
+                               snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG BORDER=0 SRC=\"%s\"> <A HREF=\"telnet://%s/\">%s</A>\n",
                                    icon_type, host, name);
 
                        } else {
-                           sprintf(tmpbuf, "<IMG BORDER=0 SRC=\"%s\"> <A HREF=\"gopher://%s/%c%s\">%s</A>\n",
+                           snprintf(tmpbuf, TEMP_BUF_SIZE,  "<IMG BORDER=0 SRC=\"%s\"> <A HREF=\"gopher://%s/%c%s\">%s</A>\n",
                                icon_type, host, gtype, escaped_selector, name);
                        }
                        safe_free(escaped_selector);
@@ -588,10 +591,10 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
                        break;
 
                    if (gopherState->cso_recno != recno) {
-                       sprintf(tmpbuf, "</PRE><HR><H2>Record# %d<br><i>%s</i></H2>\n<PRE>", recno, result);
+                       snprintf(tmpbuf,TEMP_BUF_SIZE, "</PRE><HR><H2>Record# %d<br><i>%s</i></H2>\n<PRE>", recno, result);
                        gopherState->cso_recno = recno;
                    } else {
-                       sprintf(tmpbuf, "%s\n", result);
+                       snprintf(tmpbuf,TEMP_BUF_SIZE, "%s\n", result);
                    }
                    strcat(outbuf, tmpbuf);
                    gopherState->data_in = 1;
@@ -616,7 +619,7 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
                    case 502:   /* Too Many Matches */
                        {
                            /* Print the message the server returns */
-                           sprintf(tmpbuf, "</PRE><HR><H2>%s</H2>\n<PRE>", result);
+                           snprintf(tmpbuf, TEMP_BUF_SIZE, "</PRE><HR><H2>%s</H2>\n<PRE>", result);
                            strcat(outbuf, tmpbuf);
                            gopherState->data_in = 1;
                            break;
@@ -812,13 +815,13 @@ gopherSendRequest(int fd, void *data)
     char *t;
     if (gopherState->type_id == GOPHER_CSO) {
        sscanf(gopherState->request, "?%s", query);
-       sprintf(buf, "query %s\r\nquit\r\n", query);
+       snprintf(buf, 4096, "query %s\r\nquit\r\n", query);
     } else if (gopherState->type_id == GOPHER_INDEX) {
        if ((t = strchr(gopherState->request, '?')))
            *t = '\t';
-       sprintf(buf, "%s\r\n", gopherState->request);
+       snprintf(buf, 4096, "%s\r\n", gopherState->request);
     } else {
-       sprintf(buf, "%s\r\n", gopherState->request);
+       snprintf(buf, 4096, "%s\r\n", gopherState->request);
     }
     debug(10, 5) ("gopherSendRequest: FD %d\n", fd);
     comm_write(fd,
index 9b2185bd022bf67353944ca4463622027a3b8353..b04c4ff8ab211424084e856aa0b943a4a2074690 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: http.cc,v 1.187 1997/08/26 04:21:19 wessels Exp $
+ * $Id: http.cc,v 1.188 1997/10/13 22:09:11 kostas Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -787,13 +787,13 @@ httpBuildRequestHeader(request_t * request,
     debug(11, 3) ("httpBuildRequestHeader: INPUT:\n%s\n", hdr_in);
     xstrncpy(fwdbuf, "X-Forwarded-For: ", 4096);
     xstrncpy(viabuf, "Via: ", 4096);
-    sprintf(ybuf, "%s %s HTTP/1.0",
+    snprintf(ybuf, MAX_URL + 32, "%s %s HTTP/1.0",
        RequestMethodStr[request->method],
        *request->urlpath ? request->urlpath : "/");
     httpAppendRequestHeader(hdr_out, ybuf, &len, out_sz, 1);
     /* Add IMS header */
     if (entry && entry->lastmod && request->method == METHOD_GET) {
-       sprintf(ybuf, "If-Modified-Since: %s", mkrfc1123(entry->lastmod));
+       snprintf(ybuf, MAX_URL + 32, "If-Modified-Since: %s", mkrfc1123(entry->lastmod));
        httpAppendRequestHeader(hdr_out, ybuf, &len, out_sz, 1);
        EBIT_SET(hdr_flags, HDR_IMS);
     }
@@ -838,30 +838,31 @@ httpBuildRequestHeader(request_t * request,
            if (orig_request->method == METHOD_TRACE) {
                for (s = xbuf + 13; *s && isspace(*s); s++);
                n = atoi(s);
-               sprintf(xbuf, "Max-Forwards: %d", n - 1);
+               snprintf(xbuf, 4096,  "Max-Forwards: %d", n - 1);
            }
        }
        httpAppendRequestHeader(hdr_out, xbuf, &len, out_sz - 512, 1);
     }
     hdr_len = t - hdr_in;
     if (Config.fake_ua && strstr(hdr_out, "User-Agent") == NULL) {
-       sprintf(ybuf, "User-Agent: %s", Config.fake_ua);
+       snprintf(ybuf,MAX_URL+32,  "User-Agent: %s", Config.fake_ua);
        httpAppendRequestHeader(hdr_out, ybuf, &len, out_sz, 0);
     }
-    /* Append Via: */
-    sprintf(ybuf, "%3.1f %s", orig_request->http_ver, ThisCache);
+    /* Append Via: */ 
+       /* snprintf would fail here too */
+    snprintf(ybuf, MAX_URL+32,  "%3.1f %s", orig_request->http_ver, ThisCache);
     strcat(viabuf, ybuf);
     httpAppendRequestHeader(hdr_out, viabuf, &len, out_sz, 1);
     /* Append to X-Forwarded-For: */
     strcat(fwdbuf, cfd < 0 ? "unknown" : fd_table[cfd].ipaddr);
     httpAppendRequestHeader(hdr_out, fwdbuf, &len, out_sz, 1);
     if (!EBIT_TEST(hdr_flags, HDR_HOST)) {
-       sprintf(ybuf, "Host: %s", orig_request->host);
+       snprintf(ybuf,MAX_URL+32, "Host: %s", orig_request->host);
        httpAppendRequestHeader(hdr_out, ybuf, &len, out_sz, 1);
     }
     if (!EBIT_TEST(cc_flags, CCC_MAXAGE)) {
        url = entry ? entry->url : urlCanonical(orig_request, NULL);
-       sprintf(ybuf, "Cache-control: Max-age=%d", (int) getMaxAge(url));
+       snprintf(ybuf, MAX_URL+32, "Cache-control: Max-age=%d", (int) getMaxAge(url));
        httpAppendRequestHeader(hdr_out, ybuf, &len, out_sz, 1);
        if (request->urlpath) {
            assert(strstr(url, request->urlpath));
@@ -870,9 +871,9 @@ httpBuildRequestHeader(request_t * request,
     /* maybe append Connection: Keep-Alive */
     if (BIT_TEST(flags, HTTP_KEEPALIVE)) {
        if (BIT_TEST(flags, HTTP_PROXYING)) {
-           sprintf(ybuf, "Proxy-Connection: Keep-Alive");
+           snprintf(ybuf,MAX_URL+32, "Proxy-Connection: Keep-Alive");
        } else {
-           sprintf(ybuf, "Connection: Keep-Alive");
+           snprintf(ybuf,MAX_URL+32, "Connection: Keep-Alive");
        }
        httpAppendRequestHeader(hdr_out, ybuf, &len, out_sz, 1);
     }
@@ -1282,7 +1283,7 @@ httpReplyHeader(double ver,
     int l = 0;
     int s = HTTP_REPLY_BUF_SZ;
     /* argh, ../lib/snprintf.c doesn't support '%f' */
-    sprintf(float_buf, "%3.1f", ver);
+    snprintf(float_buf,64, "%3.1f", ver);
     assert(strlen(float_buf) == 3);
     l += snprintf(buf + l, s - l, "HTTP/%s %d %s\r\n",
        float_buf,
index b11946b2a5e3164d47f0c6654dd5996b840946c2..a87cf196ffcf1b0b86bd79b6b5e5af4b5c5d3065 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: icmp.cc,v 1.41 1997/07/16 20:32:08 wessels Exp $
+ * $Id: icmp.cc,v 1.42 1997/10/13 22:09:12 kostas Exp $
  *
  * DEBUG: section 37    ICMP Routines
  * AUTHOR: Duane Wessels
@@ -275,8 +275,9 @@ icmpOpen(void)
        return;
     }
     if (pid == 0) {            /* child */
-       char *x = xcalloc(strlen(Config.debugOptions) + 32, 1);
-       sprintf(x, "SQUID_DEBUG=%s", Config.debugOptions);
+       int tmp_s;
+       char *x = xcalloc((tmp_s=strlen(Config.debugOptions) + 32), 1);
+       snprintf(x,tmp_s, "SQUID_DEBUG=%s", Config.debugOptions);
        putenv(x);
        comm_close(icmp_sock);
        dup2(child_sock, 0);
index 38d55747276f33ae0be5b2d16bbde6ea404a844c..62ddfb7f283eadf08fc417efff89d915c68eb1c3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ident.cc,v 1.32 1997/07/15 23:23:27 wessels Exp $
+ * $Id: ident.cc,v 1.33 1997/10/13 22:09:14 kostas Exp $
  *
  * DEBUG: section 30    Ident (RFC 931)
  * AUTHOR: Duane Wessels
@@ -85,7 +85,7 @@ identConnectDone(int fd, int status, void *data)
        identCallback(connState);
        return;
     }
-    sprintf(reqbuf, "%d, %d\r\n",
+    snprintf(reqbuf,BUFSIZ, "%d, %d\r\n",
        ntohs(connState->peer.sin_port),
        ntohs(connState->me.sin_port));
     comm_write(fd,
index 84a1a2ac7ab28b61df7342526b30a6f9cecb00df..697605ed82ecc916291d0904518ae39ae325c9a7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ipcache.cc,v 1.129 1997/08/25 23:45:28 wessels Exp $
+ * $Id: ipcache.cc,v 1.130 1997/10/13 22:09:15 kostas Exp $
  *
  * DEBUG: section 14    IP Cache
  * AUTHOR: Harvest Derived
@@ -734,7 +734,7 @@ ipcache_dnsDispatch(dnsserver_t * dns, ipcache_entry * i)
     }
     assert(i->status == IP_PENDING);
     buf = xcalloc(1, 256);
-    sprintf(buf, "%1.254s\n", i->name);
+    snprintf(buf, 256, "%1.254s\n", i->name);
     dns->flags |= DNS_FLAG_BUSY;
     dns->data = i;
     i->status = IP_DISPATCHED;
@@ -1105,7 +1105,7 @@ ipcacheChangeKey(ipcache_entry * i)
        debug_trap("ipcacheChangeKey: hash_remove_link() failed\n");
        return;
     }
-    sprintf(new_key, "%d/", ++index);
+    snprintf(new_key,256, "%d/", ++index);
     strncat(new_key, i->name, 128);
     debug(14, 1) ("ipcacheChangeKey: from '%s' to '%s'\n", i->name, new_key);
     safe_free(i->name);
index e625553fa7fbd18a3438cb3e060f9f56533d63d9..df66e8a2232ace6cbac6b218f2e7f9c252b14620 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: mime.cc,v 1.37 1997/08/25 03:51:50 wessels Exp $
+ * $Id: mime.cc,v 1.38 1997/10/13 22:09:16 kostas Exp $
  *
  * DEBUG: section 25    MIME Parsing
  * AUTHOR: Harvest Derived
@@ -212,13 +212,17 @@ mk_mime_hdr(char *result, const char *type, int size, time_t ttl, time_t lmt)
     expiretime = ttl ? t + ttl : 0;
     date[0] = expires[0] = last_modified[0] = '\0';
     content_length[0] = result[0] = '\0';
-    sprintf(date, "Date: %s\r\n", mkrfc1123(t));
+    snprintf(date,100, "Date: %s\r\n", mkrfc1123(t));
     if (ttl >= 0)
-       sprintf(expires, "Expires: %s\r\n", mkrfc1123(expiretime));
+       snprintf(expires, 100, "Expires: %s\r\n", mkrfc1123(expiretime));
     if (lmt)
-       sprintf(last_modified, "Last-Modified: %s\r\n", mkrfc1123(lmt));
+       snprintf(last_modified,100, "Last-Modified: %s\r\n", mkrfc1123(lmt));
     if (size > 0)
-       sprintf(content_length, "Content-Length: %d\r\n", size);
+       snprintf(content_length,100, "Content-Length: %d\r\n", size);
+
+       /* NOTE: don't know size of result thus didn't change
+          to snprintf(). Should be done sometime! */
+
     sprintf(result, "Server: %s/%s\r\n%s%s%sContent-Type: %s\r\n%s",
        appname,
        version_string,
index 952e26de7641c738148cb78217daec53505145c0..64cdb1bc292fd526d9fdb2ba30b2e275bac8c784 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: neighbors.cc,v 1.159 1997/08/25 22:35:58 wessels Exp $
+ * $Id: neighbors.cc,v 1.160 1997/10/13 22:09:17 kostas Exp $
  *
  * DEBUG: section 15    Neighbor Routines
  * AUTHOR: Harvest Derived
@@ -929,7 +929,7 @@ peerCountMcastPeersStart(void *data)
     if (p->type != PEER_MULTICAST)
        fatal_dump("peerCountMcastPeersStart: non-multicast peer");
     p->mcast.flags &= ~PEER_COUNT_EVENT_PENDING;
-    sprintf(url, "http://%s/", inet_ntoa(p->in_addr.sin_addr));
+    snprintf(url, MAX_URL, "http://%s/", inet_ntoa(p->in_addr.sin_addr));
     fake = storeCreateEntry(url, url, 0, METHOD_GET);
     psstate->request = requestLink(urlParse(METHOD_GET, url));
     psstate->entry = fake;
index 4d9fd2de009710636cf2cb92b7cdd3e7b5f9bb44..bc514f6068e0044c5ca86c4fbb2390510e033aa5 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: net_db.cc,v 1.48 1997/08/25 23:45:29 wessels Exp $
+ * $Id: net_db.cc,v 1.49 1997/10/13 22:09:17 kostas Exp $
  *
  * DEBUG: section 37    Network Measurement Database
  * AUTHOR: Duane Wessels
@@ -323,7 +323,7 @@ netdbSaveState(void *foo)
     net_db_name *x;
     struct timeval start = current_time;
     int count = 0;
-    sprintf(path, "%s/netdb_state", storeSwapDir(0));
+    snprintf(path, SQUID_MAXPATHLEN, "%s/netdb_state", storeSwapDir(0));
     fp = fopen(path, "w");
     if (fp == NULL) {
        debug(50, 1) ("netdbSaveState: %s: %s\n", path, xstrerror());
@@ -365,7 +365,7 @@ netdbReloadState(void)
     struct in_addr addr;
     int count = 0;
     struct timeval start = current_time;
-    sprintf(path, "%s/netdb_state", storeSwapDir(0));
+    snprintf(path, SQUID_MAXPATHLEN, "%s/netdb_state", storeSwapDir(0));
     fp = fopen(path, "r");
     if (fp == NULL)
        return;
index 09b97dc753cb801097fbf389c92d57ad157f9003..6f6218bb0a95176d36954fa3d9d529a3d59e8ce6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: redirect.cc,v 1.45 1997/07/15 05:34:12 wessels Exp $
+ * $Id: redirect.cc,v 1.46 1997/10/13 22:09:18 kostas Exp $
  *
  * DEBUG: section 29    Redirector
  * AUTHOR: Duane Wessels
@@ -305,7 +305,7 @@ redirectDispatch(redirector_t * redirect, redirectStateData * r)
     if ((fqdn = fqdncache_gethostbyaddr(r->client_addr, 0)) == NULL)
        fqdn = dash_str;
     buf = get_free_8k_page();
-    sprintf(buf, "%s %s/%s %s %s\n",
+    snprintf(buf,8192, "%s %s/%s %s %s\n",
        r->orig_url,
        inet_ntoa(r->client_addr),
        fqdn,
@@ -408,7 +408,7 @@ redirectOpenServers(void)
                s++;
            else
                s = prg;
-           sprintf(fd_note_buf, "%s #%d",
+           snprintf(fd_note_buf, FD_DESC_SZ, "%s #%d",
                s,
                redirect_child_table[k]->index + 1);
            fd_note(redirect_child_table[k]->fd, fd_note_buf);
index e088c3611d08212f757a69d61b70ac955aa1d242..558bb8600a5647c08091e1c1b3766d40016e5b0b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: send-announce.cc,v 1.42 1997/07/26 04:48:34 wessels Exp $
+ * $Id: send-announce.cc,v 1.43 1997/10/13 22:09:19 kostas Exp $
  *
  * DEBUG: section 27    Cache Announcer
  * AUTHOR: Duane Wessels
@@ -60,19 +60,19 @@ send_announce(const ipcache_addrs * ia, void *data)
     }
     debug(27, 0) ("Sending Announcement to %s\n", host);
     sndbuf[0] = '\0';
-    sprintf(tbuf, "cache_version SQUID/%s\n", version_string);
+    snprintf(tbuf,256, "cache_version SQUID/%s\n", version_string);
     strcat(sndbuf, tbuf);
     assert(Config.Port.http);
-    sprintf(tbuf, "Running on %s %d %d\n",
+    snprintf(tbuf,256, "Running on %s %d %d\n",
        getMyHostname(),
        (int) Config.Port.http->i,
        (int) Config.Port.icp);
     strcat(sndbuf, tbuf);
     if (Config.adminEmail) {
-       sprintf(tbuf, "cache_admin: %s\n", Config.adminEmail);
+       snprintf(tbuf,256, "cache_admin: %s\n", Config.adminEmail);
        strcat(sndbuf, tbuf);
     }
-    sprintf(tbuf, "generated %d [%s]\n",
+    snprintf(tbuf, 256, "generated %d [%s]\n",
        (int) squid_curtime,
        mkhttpdlogtime(&squid_curtime));
     strcat(sndbuf, tbuf);
index 5e5f36f99310380bd93dcb200ba96112b084d6e4..0421d7e06b0119b3213eee8364d19cfeb31c4ed3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ssl.cc,v 1.61 1997/08/10 04:42:46 wessels Exp $
+ * $Id: ssl.cc,v 1.62 1997/10/13 22:09:20 kostas Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -406,7 +406,7 @@ sslProxyConnected(int fd, void *data)
 {
     SslStateData *sslState = data;
     debug(26, 3) ("sslProxyConnected: FD %d sslState=%p\n", fd, sslState);
-    sprintf(sslState->client.buf, "CONNECT %s HTTP/1.0\r\n\r\n", sslState->url);
+    snprintf(sslState->client.buf, sslState->client.len, "CONNECT %s HTTP/1.0\r\n\r\n", sslState->url);
     debug(26, 3) ("sslProxyConnected: Sending 'CONNECT %s HTTP/1.0'\n", sslState->url);
     sslState->client.len = strlen(sslState->client.buf);
     sslState->client.offset = 0;
index 8adad8beb9cd21f65a0f34e73e8438a269fdb999..672d899e8f9d4eb716d25b3d21ec5db672e2e93a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.156 1997/08/25 22:36:00 wessels Exp $
+ * $Id: stat.cc,v 1.157 1997/10/13 22:09:20 kostas Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -276,7 +276,7 @@ static const char *
 describeStatuses(const StoreEntry * entry)
 {
     LOCAL_ARRAY(char, buf, 256);
-    sprintf(buf, "%-13s %-13s %-12s %-12s",
+    snprintf(buf,256, "%-13s %-13s %-12s %-12s",
        storeStatusStr[entry->store_status],
        memStatusStr[entry->mem_status],
        swapStatusStr[entry->swap_status],
@@ -324,7 +324,7 @@ static const char *
 describeTimestamps(const StoreEntry * entry)
 {
     LOCAL_ARRAY(char, buf, 256);
-    sprintf(buf, "LV:%-9d LU:%-9d LM:%-9d EX:%-9d",
+    snprintf(buf,256, "LV:%-9d LU:%-9d LM:%-9d EX:%-9d",
        (int) entry->timestamp,
        (int) entry->lastref,
        (int) entry->lastmod,
@@ -448,7 +448,7 @@ fdRemoteAddr(const fde * f)
     LOCAL_ARRAY(char, buf, 32);
     if (f->type != FD_SOCKET)
        return null_string;
-    sprintf(buf, "%s.%d", f->ipaddr, (int) f->remote_port);
+    snprintf(buf, 32, "%s.%d", f->ipaddr, (int) f->remote_port);
     return buf;
 }
 
index 71aaf1b817bf319bb396346e67aee26890979358..29e189a43b4125403b978328d23d02248a5e2662 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.284 1997/08/25 23:45:30 wessels Exp $
+ * $Id: store.cc,v 1.285 1997/10/13 22:09:22 kostas Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -494,7 +494,7 @@ storeLog(int tag, const StoreEntry * e)
        mem->log_url = xstrdup(e->url);
     }
     reply = mem->reply;
-    sprintf(logmsg, "%9d.%03d %-7s %08X %4d %9d %9d %9d %s %d/%d %s %s\n",
+    snprintf(logmsg, MAX_URL<<1 , "%9d.%03d %-7s %08X %4d %9d %9d %9d %s %d/%d %s %s\n",
        (int) current_time.tv_sec,
        (int) current_time.tv_usec / 1000,
        storeLogTags[tag],
@@ -617,7 +617,7 @@ storeGeneratePrivateKey(const char *url, method_t method, int num)
     }
     debug(20, 3) ("storeGeneratePrivateKey: '%s'\n", url);
     key_temp_buffer[0] = '\0';
-    sprintf(key_temp_buffer, "%d/%s/%s",
+    snprintf(key_temp_buffer, MAX_URL+100, "%d/%s/%s",
        num,
        RequestMethodStr[method],
        url);
@@ -638,7 +638,7 @@ storeGeneratePublicKey(const char *url, method_t method)
     case METHOD_HEAD:
     case METHOD_CONNECT:
     case METHOD_TRACE:
-       sprintf(key_temp_buffer, "/%s/%s", RequestMethodStr[method], url);
+       snprintf(key_temp_buffer,MAX_URL+100, "/%s/%s", RequestMethodStr[method], url);
        return key_temp_buffer;
        /* NOTREACHED */
        break;
@@ -950,7 +950,7 @@ storeAppendPrintf(va_alist)
     fmt = va_arg(args, char *);
 #endif
     buf[0] = '\0';
-    vsprintf(buf, fmt, args);
+    vsnprintf(buf,4096, fmt, args);
     storeAppend(e, buf, strlen(buf));
     va_end(args);
 }
@@ -2450,7 +2450,7 @@ storeWriteCleanLogs(int reopen)
        assert(dirn < Config.cacheSwap.n_configured);
        if (fd[dirn] < 0)
            continue;
-       sprintf(line, "%08x %08x %08x %08x %08x %9d %6d %08x %s\n",
+       snprintf(line, 16384, "%08x %08x %08x %08x %08x %9d %6d %08x %s\n",
            (int) e->swap_file_number,
            (int) e->timestamp,
            (int) e->lastref,
@@ -2559,13 +2559,13 @@ storeRotateLog(void)
     /* Rotate numbers 0 through N up one */
     for (i = Config.Log.rotateNumber; i > 1;) {
        i--;
-       sprintf(from, "%s.%d", fname, i - 1);
-       sprintf(to, "%s.%d", fname, i);
+       snprintf(from,MAXPATHLEN, "%s.%d", fname, i - 1);
+       snprintf(to, MAXPATHLEN, "%s.%d", fname, i);
        rename(from, to);
     }
     /* Rotate the current log to .0 */
     if (Config.Log.rotateNumber > 0) {
-       sprintf(to, "%s.%d", fname, 0);
+       snprintf(to,MAXPATHLEN, "%s.%d", fname, 0);
        rename(fname, to);
     }
     storelog_fd = file_open(fname, O_WRONLY | O_CREAT, NULL, NULL);
index 96fddce7a464d1818fc122c57be04f71da23b332..494f56170004c7e2c38bdbfe9fc0c8976f2d378e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir.cc,v 1.27 1997/07/16 22:58:26 wessels Exp $
+ * $Id: store_dir.cc,v 1.28 1997/10/13 22:09:23 kostas Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -46,7 +46,7 @@ storeSwapFullPath(int fn, char *fullpath)
     if (!fullpath)
        fullpath = fullfilename;
     fullpath[0] = '\0';
-    sprintf(fullpath, "%s/%02X/%02X/%08X",
+    snprintf(fullpath,SQUID_MAXPATHLEN, "%s/%02X/%02X/%08X",
        Config.cacheSwap.swapDirs[dirn].path,
        filn % Config.cacheSwap.swapDirs[dirn].l1,
        filn / Config.cacheSwap.swapDirs[dirn].l1 % Config.cacheSwap.swapDirs[dirn].l2,
@@ -64,7 +64,7 @@ storeSwapSubSubDir(int fn, char *fullpath)
     if (!fullpath)
        fullpath = fullfilename;
     fullpath[0] = '\0';
-    sprintf(fullpath, "%s/%02X/%02X",
+    snprintf(fullpath,SQUID_MAXPATHLEN, "%s/%02X/%02X",
        Config.cacheSwap.swapDirs[dirn].path,
        filn % Config.cacheSwap.swapDirs[dirn].l1,
        filn / Config.cacheSwap.swapDirs[dirn].l1 % Config.cacheSwap.swapDirs[dirn].l2);
@@ -81,7 +81,9 @@ storeVerifyOrCreateDir(const char *path)
     }
     safeunlink(path, 1);
     if (mkdir(path, 0777) < 0) {
-       if (errno != EEXIST) {
+       if (errno != EEXIST) {    
+         /* NOTE: couldn't figure size of tmp_error_buf, thus didn't
+               change to snprintf()  ... yet */
            sprintf(tmp_error_buf, "Failed to create swap directory %s: %s",
                path,
                xstrerror());
@@ -90,6 +92,8 @@ storeVerifyOrCreateDir(const char *path)
     }
     debug(47, 1) ("Created directory %s\n", path);
     if (stat(path, &sb) < 0 || !S_ISDIR(sb.st_mode)) {
+          /* NOTE: couldn't figure size of tmp_error_buf, thus didn't
+                change to snprintf()  ... yet */
        sprintf(tmp_error_buf,
            "Failed to create directory %s: %s", path, xstrerror());
        fatal(tmp_error_buf);
@@ -119,12 +123,12 @@ storeCreateSwapSubDirs(int j)
     SwapDir *SD = &Config.cacheSwap.swapDirs[j];
     LOCAL_ARRAY(char, name, MAXPATHLEN);
     for (i = 0; i < SD->l1; i++) {
-       sprintf(name, "%s/%02X", SD->path, i);
+       snprintf(name,MAXPATHLEN, "%s/%02X", SD->path, i);
        if (storeVerifyOrCreateDir(name) == 0)
            continue;
        debug(47, 1) ("Making directories in %s\n", name);
        for (k = 0; k < SD->l2; k++) {
-           sprintf(name, "%s/%02X/%02X", SD->path, i, k);
+           snprintf(name, MAXPATHLEN, "%s/%02X/%02X", SD->path, i, k);
            storeVerifyOrCreateDir(name);
        }
     }
@@ -219,7 +223,7 @@ storeDirSwapLog(const StoreEntry * e)
     if (BIT_TEST(e->flag, KEY_PRIVATE))
        debug(0, 0) ("storeDirSwapLog: PRIVATE: %s\n", e->url);
     /* Note this printf format appears in storeWriteCleanLog() too */
-    sprintf(logmsg, "%08x %08x %08x %08x %08x %9d %6d %08x %s\n",
+    snprintf(logmsg, MAX_URL << 1 , "%08x %08x %08x %08x %08x %9d %6d %08x %s\n",
        (int) e->swap_file_number,
        (int) e->timestamp,
        (int) e->lastref,
@@ -245,7 +249,7 @@ storeDirSwapLogFile(int dirn, const char *ext)
     if (Config.Log.swap) {
        xstrncpy(path, Config.Log.swap, SQUID_MAXPATHLEN - 64);
        strcat(path, ".");
-       sprintf(digit, "%02d", dirn);
+       snprintf(digit, 32, "%02d", dirn);
        strncat(path, digit, 3);
     } else {
        xstrncpy(path, storeSwapDir(dirn), SQUID_MAXPATHLEN - 64);
index e13b90266945cbf05c727208f2d5966c47c50ddc..bcbd98f7c64ff968a820476db2798d909a2fccb1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.cc,v 1.120 1997/08/25 22:36:03 wessels Exp $
+ * $Id: tools.cc,v 1.121 1997/10/13 22:09:24 kostas Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -149,7 +149,7 @@ static char *
 dead_msg(void)
 {
     LOCAL_ARRAY(char, msg, 1024);
-    sprintf(msg, DEAD_MSG, version_string, version_string);
+    snprintf(msg,1024, DEAD_MSG, version_string, version_string);
     return msg;
 }
 
@@ -167,7 +167,7 @@ mail_warranty(void)
     fprintf(fp, "To: %s\n", Config.adminEmail);
     fprintf(fp, "Subject: %s\n", dead_msg());
     fclose(fp);
-    sprintf(command, "mail %s < %s", Config.adminEmail, filename);
+    snprintf(command,256, "mail %s < %s", Config.adminEmail, filename);
     system(command);           /* XXX should avoid system(3) */
     unlink(filename);
 }
@@ -608,7 +608,7 @@ writePidFile(void)
        debug_trap("Could not write pid file");
        return;
     }
-    sprintf(buf, "%d\n", (int) getpid());
+    snprintf(buf,32, "%d\n", (int) getpid());
     write(fd, buf, strlen(buf));
     file_close(fd);
 }
@@ -658,6 +658,8 @@ setMaxFD(void)
        if (rl.rlim_cur > rl.rlim_max)
            Squid_MaxFD = rl.rlim_cur = rl.rlim_max;
        if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
+          /* NOTE: couldn't figure size of tmp_error_buf, thus didn't
+                change to snprintf()  ... yet */
            sprintf(tmp_error_buf, "setrlimit: RLIMIT_NOFILE: %s", xstrerror());
            fatal_dump(tmp_error_buf);
        }
@@ -670,6 +672,8 @@ setMaxFD(void)
        if (rl.rlim_cur > rl.rlim_max)
            Squid_MaxFD = rl.rlim_cur = rl.rlim_max;
        if (setrlimit(RLIMIT_OFILE, &rl) < 0) {
+          /* NOTE: couldn't figure size of tmp_error_buf, thus didn't
+                change to snprintf()  ... yet */
            sprintf(tmp_error_buf, "setrlimit: RLIMIT_OFILE: %s", xstrerror());
            fatal_dump(tmp_error_buf);
        }
@@ -685,6 +689,8 @@ setMaxFD(void)
     } else if (rl.rlim_max > rl.rlim_cur) {
        rl.rlim_cur = rl.rlim_max;      /* set it to the max */
        if (setrlimit(RLIMIT_DATA, &rl) < 0) {
+          /* NOTE: couldn't figure size of tmp_error_buf, thus didn't
+                change to snprintf()  ... yet */
            sprintf(tmp_error_buf, "setrlimit: RLIMIT_DATA: %s", xstrerror());
            fatal_dump(tmp_error_buf);
        }
@@ -696,6 +702,8 @@ setMaxFD(void)
     } else if (rl.rlim_max > rl.rlim_cur) {
        rl.rlim_cur = rl.rlim_max;      /* set it to the max */
        if (setrlimit(RLIMIT_VMEM, &rl) < 0) {
+          /* NOTE: couldn't figure size of tmp_error_buf, thus didn't
+                change to snprintf()  ... yet */
            sprintf(tmp_error_buf, "setrlimit: RLIMIT_VMEM: %s", xstrerror());
            fatal_dump(tmp_error_buf);
        }
index 585fcc1d882867865283cd36d3b28a53509cc1e8..8e1f0671fbd9e7e310dee8df8f749a6a14ae9c26 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tunnel.cc,v 1.61 1997/08/10 04:42:46 wessels Exp $
+ * $Id: tunnel.cc,v 1.62 1997/10/13 22:09:20 kostas Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -406,7 +406,7 @@ sslProxyConnected(int fd, void *data)
 {
     SslStateData *sslState = data;
     debug(26, 3) ("sslProxyConnected: FD %d sslState=%p\n", fd, sslState);
-    sprintf(sslState->client.buf, "CONNECT %s HTTP/1.0\r\n\r\n", sslState->url);
+    snprintf(sslState->client.buf, sslState->client.len, "CONNECT %s HTTP/1.0\r\n\r\n", sslState->url);
     debug(26, 3) ("sslProxyConnected: Sending 'CONNECT %s HTTP/1.0'\n", sslState->url);
     sslState->client.len = strlen(sslState->client.buf);
     sslState->client.offset = 0;
index bf448d0036fb6c5ce13db68477b2dca73c441f04..ffae27e7fb5c9cbc36a6fb489b1fbbcae732139e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: url.cc,v 1.63 1997/08/24 01:49:26 wessels Exp $
+ * $Id: url.cc,v 1.64 1997/10/13 22:09:25 kostas Exp $
  *
  * DEBUG: section 23    URL Parsing
  * AUTHOR: Duane Wessels
@@ -280,13 +280,13 @@ urlCanonical(const request_t * request, char *buf)
        buf = urlbuf;
     switch (request->method) {
     case METHOD_CONNECT:
-       sprintf(buf, "%s:%d", request->host, request->port);
+       snprintf(buf,MAX_URL, "%s:%d", request->host, request->port);
        break;
     default:
        portbuf[0] = '\0';
        if (request->port != urlDefaultPort(request->protocol))
-           sprintf(portbuf, ":%d", request->port);
-       sprintf(buf, "%s://%s%s%s%s%s",
+           snprintf(portbuf,32,  ":%d", request->port);
+       snprintf(buf, MAX_URL, "%s://%s%s%s%s%s",
            ProtocolStr[request->protocol],
            request->login,
            *request->login ? "@" : null_string,
@@ -306,13 +306,13 @@ urlCanonicalClean(const request_t * request)
     char *t;
     switch (request->method) {
     case METHOD_CONNECT:
-       sprintf(buf, "%s:%d", request->host, request->port);
+       snprintf(buf, MAX_URL, "%s:%d", request->host, request->port);
        break;
     default:
        portbuf[0] = '\0';
        if (request->port != urlDefaultPort(request->protocol))
-           sprintf(portbuf, ":%d", request->port);
-       sprintf(buf, "%s://%s%s%s",
+           snprintf(portbuf,32, ":%d", request->port);
+       snprintf(buf,MAX_URL, "%s://%s%s%s",
            ProtocolStr[request->protocol],
            request->host,
            portbuf,
index c875aa3a38bb447832201276cbae2c13395c0871..31743de26837bbb29d50f2d242bdc4e92814d400 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: useragent.cc,v 1.10 1997/07/26 04:48:35 wessels Exp $
+ * $Id: useragent.cc,v 1.11 1997/10/13 22:09:26 kostas Exp $
  *
  * DEBUG: section 40    User-Agent logging
  * AUTHOR: Joe Ramey <ramey@csc.ti.com>
@@ -81,13 +81,13 @@ useragentRotateLog(void)
     /* Rotate numbers 0 through N up one */
     for (i = Config.Log.rotateNumber; i > 1;) {
        i--;
-       sprintf(from, "%s.%d", fname, i - 1);
-       sprintf(to, "%s.%d", fname, i);
+       snprintf(from,MAXPATHLEN, "%s.%d", fname, i - 1);
+       snprintf(to,MAXPATHLEN, "%s.%d", fname, i);
        rename(from, to);
     }
     /* Rotate the current log to .0 */
     if (Config.Log.rotateNumber > 0) {
-       sprintf(to, "%s.%d", fname, 0);
+       snprintf(to, MAXPATHLEN, "%s.%d", fname, 0);
        rename(fname, to);
     }
     useragentOpenLog();
index 68212b5e3936a1e1cc4058648c1d2447bc4a0039..a4b8536a909ad07d93d55250dfa27f2e7df26357 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: wais.cc,v 1.80 1997/07/28 06:41:07 wessels Exp $
+ * $Id: wais.cc,v 1.81 1997/10/13 22:09:26 kostas Exp $
  *
  * DEBUG: section 24    WAIS Relay
  * AUTHOR: Harvest Derived
@@ -284,10 +284,10 @@ waisSendRequest(int fd, void *data)
     buf = xcalloc(1, len + 1);
 
     if (waisState->request_hdr)
-       sprintf(buf, "%s %s %s\r\n", Method, waisState->request,
+       snprintf(buf, len+1, "%s %s %s\r\n", Method, waisState->request,
            waisState->request_hdr);
     else
-       sprintf(buf, "%s %s\r\n", Method, waisState->request);
+       snprintf(buf, len+1, "%s %s\r\n", Method, waisState->request);
     debug(24, 6) ("waisSendRequest: buf: %s\n", buf);
     comm_write(fd,
        buf,