From 3c95f40e6ee907804adc1c443c4efed1222f3589 Mon Sep 17 00:00:00 2001 Message-Id: <3c95f40e6ee907804adc1c443c4efed1222f3589.1715373967.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 17 Nov 2013 10:55:40 +0000 Subject: [PATCH] Use private *printf functions a bit more widely. Organization: Straylight/Edgeware From: Richard Kettlewell --- lib/addr.c | 4 ++-- lib/client.c | 4 ++-- lib/hex.c | 5 +++-- lib/mime.c | 5 +++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/addr.c b/lib/addr.c index bb4f06c..5bc5bdf 100644 --- a/lib/addr.c +++ b/lib/addr.c @@ -321,7 +321,7 @@ void netaddress_format(const struct netaddress *na, if(na->port != -1) { char buffer[64]; - snprintf(buffer, sizeof buffer, "%d", na->port); + byte_snprintf(buffer, sizeof buffer, "%d", na->port); vector_append(v, xstrdup(buffer)); } vector_terminate(v); @@ -349,7 +349,7 @@ struct addrinfo *netaddress_resolve(const struct netaddress *na, hints->ai_family = na->af; hints->ai_protocol = protocol; hints->ai_flags = passive ? AI_PASSIVE : 0; - snprintf(service, sizeof service, "%d", na->port); + byte_snprintf(service, sizeof service, "%d", na->port); rc = getaddrinfo(na->address, service, hints, &res); if(rc) { disorder_error(0, "getaddrinfo %s %d: %s", diff --git a/lib/client.c b/lib/client.c index 7ae0d07..2fe77b8 100644 --- a/lib/client.c +++ b/lib/client.c @@ -243,13 +243,13 @@ static int disorder_simple_v(disorder_client *c, } else if(arg == disorder__integer) { long n = va_arg(ap, long); char buffer[16]; - snprintf(buffer, sizeof buffer, "%ld", n); + byte_snprintf(buffer, sizeof buffer, "%ld", n); dynstr_append(&d, ' '); dynstr_append_string(&d, buffer); } else if(arg == disorder__time) { time_t n = va_arg(ap, time_t); char buffer[16]; - snprintf(buffer, sizeof buffer, "%lld", (long long)n); + byte_snprintf(buffer, sizeof buffer, "%lld", (long long)n); dynstr_append(&d, ' '); dynstr_append_string(&d, buffer); } else { diff --git a/lib/hex.c b/lib/hex.c index efd14b1..efe8425 100644 --- a/lib/hex.c +++ b/lib/hex.c @@ -1,6 +1,6 @@ /* * This file is part of DisOrder - * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell + * Copyright (C) 2004, 2005, 2007-9, 2013 Richard Kettlewell * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include "hex.h" #include "mem.h" #include "log.h" +#include "printf.h" /** @brief Convert a byte sequence to hex * @param ptr Pointer to first byte @@ -32,7 +33,7 @@ char *hex(const uint8_t *ptr, size_t n) { char *buf = xmalloc_noptr(n * 2 + 1), *p = buf; while(n-- > 0) - p += sprintf(p, "%02x", (unsigned)*ptr++); + p += byte_snprintf(p, 3, "%02x", (unsigned)*ptr++); *p = 0; return buf; } diff --git a/lib/mime.c b/lib/mime.c index 48354b3..00a3c72 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -1,6 +1,6 @@ /* * This file is part of DisOrder - * Copyright (C) 2005, 2007, 2008 Richard Kettlewell + * Copyright (C) 2005, 2007-10, 2013 Richard Kettlewell * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ #include "log.h" #include "base64.h" #include "kvp.h" +#include "printf.h" /** @brief Match whitespace characters */ static int whitespace(int c) { @@ -712,7 +713,7 @@ char *mime_to_qp(const char *text) { ++linelength; } else { /* Anything else that needs encoding */ - snprintf(buffer, sizeof buffer, "=%02X", c); + byte_snprintf(buffer, sizeof buffer, "=%02X", c); dynstr_append_string(d, buffer); linelength += 3; } -- [mdw]