* remove snprintf
authorWilfried Göesgens <willi@citadel.org>
Sun, 13 Jan 2008 22:03:47 +0000 (22:03 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 13 Jan 2008 22:03:47 +0000 (22:03 +0000)
* urlesc is in libcitadel, don't keep a local copy of it.

webcit/tcp_sockets.c
webcit/webcit.c
webcit/webcit.h

index a348f1e0eca4b089b9e6f29ca98e2abf7199e776..59cfcdd7afdecd5fab73da10efab8013f083d43f 100644 (file)
@@ -220,13 +220,16 @@ void serv_printf(const char *format,...)
 {
        va_list arg_ptr;
        char buf[SIZ];
+       size_t len;
 
        va_start(arg_ptr, format);
        vsnprintf(buf, sizeof buf, format, arg_ptr);
        va_end(arg_ptr);
 
-       strcat(buf, "\n");
-       serv_write(buf, strlen(buf));
+       len = strlen(buf);
+       buf[len++] = '\n';
+       buf[len] = '\0';
+       serv_write(buf, len);
 #ifdef SERV_TRACE
        lprintf(9, "<%s", buf);
 #endif
index 89b237e8aa56fae1c9c341ec66394a8819401600..38c617c53fd0626719ea7fe45e8176fe3dd4c05c 100644 (file)
@@ -295,35 +295,6 @@ void escputs(char *strbuf)
        escputs1(strbuf, 0, 0);
 }
 
-/** 
- * \brief Escape a string for feeding out as a URL.
- * \param outbuf the output buffer
- * \param strbuf the input buffer
- */
-void urlesc(char *outbuf, char *strbuf)
-{
-       int a, b, c, len, eclen, olen;
-       char *ec = " +#&;`'|*?-~<>^()[]{}/$\"\\";
-
-       strcpy(outbuf, "");
-       len = strlen(strbuf);
-       eclen = strlen(ec);
-       olen = 0;
-       for (a = 0; a < len; ++a) {
-               c = 0;
-               for (b = 0; b < eclen; ++b) {
-                       if (strbuf[a] == ec[b])
-                               c = 1;
-               }
-               if (c == 1) {
-                       sprintf(&outbuf[olen], "%%%02x", strbuf[a]);
-                       olen += 3;
-               }
-               else 
-                       outbuf[olen ++] = strbuf[a];
-       }
-       outbuf[olen] = '\0';
-}
 
 /**
  * \brief urlescape buffer and print it to the client
@@ -333,7 +304,7 @@ void urlescputs(char *strbuf)
 {
        char outbuf[SIZ];
        
-       urlesc(outbuf, strbuf);
+       urlesc(outbuf, SIZ, strbuf);
        wprintf("%s", outbuf);
 }
 
@@ -1282,7 +1253,7 @@ void session_loop(struct httprequest *req)
        if (ContentLength > 0) {
                content = malloc(ContentLength + SIZ);
                memset(content, 0, ContentLength + SIZ);
-               sprintf(content, "Content-type: %s\n"
+               snprintf(content,  ContentLength + SIZ, "Content-type: %s\n"
                                "Content-length: %d\n\n",
                                ContentType, ContentLength);
                body_start = strlen(content);
@@ -1388,7 +1359,7 @@ void session_loop(struct httprequest *req)
        if (!WC->connected) {
                if (!strcasecmp(ctdlhost, "uds")) {
                        /* unix domain socket */
-                       sprintf(buf, "%s/citadel.socket", ctdlport);
+                       snprintf(buf, SIZ, "%s/citadel.socket", ctdlport);
                        WC->serv_sock = uds_connectsock(buf);
                }
                else {
@@ -1681,7 +1652,7 @@ void session_loop(struct httprequest *req)
        } else if (!strcasecmp(action, "editinfo")) {
                save_edit(_("Room info"), "EINF 1", 1);
        } else if (!strcasecmp(action, "display_editbio")) {
-               sprintf(buf, "RBIO %s", WC->wc_fullname);
+               snprintf(buf, SIZ, "RBIO %s", WC->wc_fullname);
                display_edit(_("Your bio"), "NOOP", buf, "editbio", 3);
        } else if (!strcasecmp(action, "editbio")) {
                save_edit(_("Your bio"), "EBIO", 0);
@@ -1710,13 +1681,13 @@ void session_loop(struct httprequest *req)
        } else if (!strcasecmp(action, "create_floor")) {
                create_floor();
        } else if (!strcasecmp(action, "display_editfloorpic")) {
-               sprintf(buf, "UIMG 0|_floorpic_|%s",
+               snprintf(buf, SIZ, "UIMG 0|_floorpic_|%s",
                        bstr("which_floor"));
                display_graphics_upload(_("the icon for this floor"),
                                        buf,
                                        "editfloorpic");
        } else if (!strcasecmp(action, "editfloorpic")) {
-               sprintf(buf, "UIMG 1|_floorpic_|%s",
+               snprintf(buf, SIZ, "UIMG 1|_floorpic_|%s",
                        bstr("which_floor"));
                do_graphics_upload(buf);
        } else if (!strcasecmp(action, "display_reg")) {
index 39a85b362b4766412a4bf248b6bafbfc0e810fc7..dbd47b9d7556f1fd21376cc2b231754e077f345f 100644 (file)
@@ -491,7 +491,6 @@ void pullquote_fmout(void);
 void wDumpContent(int);
 void serv_printf(const char *format,...);
 char *bstr(char *key);
-void urlesc(char *, char *);
 void urlescputs(char *);
 void jsesc(char *, size_t, char *);
 void jsescputs(char *);