From: Marko Kreen Date: Sun, 23 May 2010 08:06:40 +0000 (+0300) Subject: convert few remaining sprintf() uses to snprintf() X-Git-Tag: pgbouncer_1_4_rc3~63 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=160c0124da2464970936869bbd897616958d40af;p=pgbouncer convert few remaining sprintf() uses to snprintf() --- diff --git a/src/loader.c b/src/loader.c index 8f1c6b1..1bf043c 100644 --- a/src/loader.c +++ b/src/loader.c @@ -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; } diff --git a/src/main.c b/src/main.c index 141e6cf..38cd346 100644 --- a/src/main.c +++ b/src/main.c @@ -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) diff --git a/src/pktbuf.c b/src/pktbuf.c index bcd30cc..3410c21 100644 --- a/src/pktbuf.c +++ b/src/pktbuf.c @@ -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 *);