chiark / gitweb /
Use private *printf functions a bit more widely.
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 17 Nov 2013 10:55:40 +0000 (10:55 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 17 Nov 2013 10:55:40 +0000 (10:55 +0000)
lib/addr.c
lib/client.c
lib/hex.c
lib/mime.c

index bb4f06cdbd8ab7f8514b988c053a9bf645d95048..5bc5bdf9e6d57e991a28a5a8e175e2c71d8dd13c 100644 (file)
@@ -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",
index 7ae0d07dd68b6ee4753ba7d64657fd24c5287917..2fe77b870a72ae0e7aca00af85db48763de2e378 100644 (file)
@@ -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 {
index efd14b11c5d5ab4d194a877f8397bf61da5740eb..efe842598137376af02e6f5355c354226c729cdd 100644 (file)
--- 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;
 }
index 48354b3d7ed636958bc2765cbfa3f1c97f99da44..00a3c7209377c5e7afa43c6da631a280af3dc936 100644 (file)
@@ -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;
     }