]> granicus.if.org Git - pgbouncer/commitdiff
convert few remaining sprintf() uses to snprintf()
authorMarko Kreen <markokr@gmail.com>
Sun, 23 May 2010 08:06:40 +0000 (11:06 +0300)
committerMarko Kreen <markokr@gmail.com>
Fri, 11 Jun 2010 13:08:19 +0000 (16:08 +0300)
src/loader.c
src/main.c
src/pktbuf.c

index 8f1c6b17ae8366b2bca3c02c9e43f3f66805b5fa..1bf043ccba881c5943dce4a9cb9df758e45a1be7 100644 (file)
@@ -555,7 +555,7 @@ const char *cf_get_int(ConfElem *elem)
        int val;
 
        val = *(int *)elem->dst;
-       sprintf(numbuf, "%d", val);
+       snprintf(numbuf, sizeof(numbuf), "%d", val);
        return numbuf;
 }
 bool cf_set_time(ConfElem *elem, const char *val, PgSocket *console)
@@ -575,7 +575,7 @@ const char *cf_get_time(ConfElem *elem)
        usec_t val;
 
        val = *(usec_t *)elem->dst;
-       sprintf(numbuf, "%d", (int)(val / USEC));
+       snprintf(numbuf, sizeof(numbuf), "%d", (int)(val / USEC));
        return numbuf;
 }
 
index 141e6cfedd69612e0da022aeab49d1ebb2c5858e..38cd34642bca57ffe2cac9f62db617dd194f7d6a 100644 (file)
@@ -536,7 +536,7 @@ static void write_pidfile(void)
                return;
 
        pid = getpid();
-       sprintf(buf, "%u", (unsigned)pid);
+       snprintf(buf, sizeof(buf), "%u", (unsigned)pid);
 
        fd = open(cf_pidfile, O_WRONLY | O_CREAT | O_EXCL, 0644);
        if (fd < 0)
index bcd30cc81fdfe03192b017fa50a4c6c2e84f69d9..3410c216dca2836b80db2d4bc866c6485f41705e 100644 (file)
@@ -402,10 +402,10 @@ void pktbuf_write_DataRow(PktBuf *buf, const char *tupdesc, ...)
        va_start(ap, tupdesc);
        for (i = 0; i < ncol; i++) {
                if (tupdesc[i] == 'i') {
-                       sprintf(tmp, "%d", va_arg(ap, int));
+                       snprintf(tmp, sizeof(tmp), "%d", va_arg(ap, int));
                        val = tmp;
                } else if (tupdesc[i] == 'q') {
-                       sprintf(tmp, "%" PRIu64, va_arg(ap, uint64_t));
+                       snprintf(tmp, sizeof(tmp), "%" PRIu64, va_arg(ap, uint64_t));
                        val = tmp;
                } else if (tupdesc[i] == 's') {
                        val = va_arg(ap, char *);