diff options
author | Russ Allbery <eagle@eyrie.org> | 2016-09-24 21:16:33 -0700 |
---|---|---|
committer | Russ Allbery <eagle@eyrie.org> | 2016-09-24 21:16:33 -0700 |
commit | 6801d0b3ae73ecdec73cd46fd4e9d9fe8687ded9 (patch) | |
tree | 9e6a89b60daa29f32dca439ad49ae136f9597141 /util | |
parent | e444fc0a1c847982446e64fbffe17435c2092f66 (diff) |
Update to rra-c-util 6.1
* Correct return-value checks for snprintf.
* Adjust Test::RRA::Config for new load path behavior in Perl 5.22.2.
and other minor fixes.
Diffstat (limited to 'util')
-rw-r--r-- | util/buffer.c | 5 | ||||
-rw-r--r-- | util/buffer.h | 2 | ||||
-rw-r--r-- | util/messages-krb5.h | 4 | ||||
-rw-r--r-- | util/messages.c | 5 | ||||
-rw-r--r-- | util/messages.h | 2 | ||||
-rw-r--r-- | util/network.c | 4 |
6 files changed, 13 insertions, 9 deletions
diff --git a/util/buffer.c b/util/buffer.c index 7ad4767..a2d14c0 100644 --- a/util/buffer.c +++ b/util/buffer.c @@ -16,6 +16,7 @@ * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>. * * Written by Russ Allbery <eagle@eyrie.org> + * Copyright 2015, 2016 Russ Allbery <eagle@eyrie.org> * Copyright 2011, 2012, 2014 * The Board of Trustees of the Leland Stanford Junior University * Copyright (c) 2004, 2005, 2006 @@ -155,13 +156,13 @@ buffer_append_vsprintf(struct buffer *buffer, const char *format, va_list args) va_end(args_copy); if (status < 0) return; - if ((size_t) status + 1 <= avail) { + if ((size_t) status < avail) { buffer->left += status; } else { buffer_resize(buffer, total + status + 1); avail = buffer->size - total; status = vsnprintf(buffer->data + total, avail, format, args); - if (status < 0 || (size_t) status + 1 > avail) + if (status < 0 || (size_t) status >= avail) return; buffer->left += status; } diff --git a/util/buffer.h b/util/buffer.h index 754d42e..33cdfc6 100644 --- a/util/buffer.h +++ b/util/buffer.h @@ -16,7 +16,7 @@ * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>. * * Written by Russ Allbery <eagle@eyrie.org> - * Copyright 2014 Russ Allbery <eagle@eyrie.org> + * Copyright 2014, 2015 Russ Allbery <eagle@eyrie.org> * Copyright 2011, 2012 * The Board of Trustees of the Leland Stanford Junior University * Copyright (c) 2004, 2005, 2006 diff --git a/util/messages-krb5.h b/util/messages-krb5.h index 3fc0862..88efbb0 100644 --- a/util/messages-krb5.h +++ b/util/messages-krb5.h @@ -44,9 +44,9 @@ BEGIN_DECLS * an error code to get the Kerberos error. */ void die_krb5(krb5_context, krb5_error_code, const char *, ...) - __attribute__((__nonnull__, __noreturn__, __format__(printf, 3, 4))); + __attribute__((__nonnull__(3), __noreturn__, __format__(printf, 3, 4))); void warn_krb5(krb5_context, krb5_error_code, const char *, ...) - __attribute__((__nonnull__, __format__(printf, 3, 4))); + __attribute__((__nonnull__(3), __format__(printf, 3, 4))); /* Undo default visibility change. */ #pragma GCC visibility pop diff --git a/util/messages.c b/util/messages.c index b5c2dba..e63f7c3 100644 --- a/util/messages.c +++ b/util/messages.c @@ -54,7 +54,8 @@ * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>. * * Written by Russ Allbery <eagle@eyrie.org> - * Copyright 2008, 2009, 2010, 2013 + * Copyright 2015, 2016 Russ Allbery <eagle@eyrie.org> + * Copyright 2008, 2009, 2010, 2013, 2014 * The Board of Trustees of the Leland Stanford Junior University * Copyright (c) 2004, 2005, 2006 * by Internet Systems Consortium, Inc. ("ISC") @@ -238,7 +239,7 @@ message_log_syslog(int pri, size_t len, const char *fmt, va_list args, int err) exit(message_fatal_cleanup ? (*message_fatal_cleanup)() : 1); } status = vsnprintf(buffer, len + 1, fmt, args); - if (status < 0) { + if (status < 0 || (size_t) status >= len + 1) { warn("failed to format output with vsnprintf in syslog handler"); free(buffer); return; diff --git a/util/messages.h b/util/messages.h index cf91ba7..a15a03e 100644 --- a/util/messages.h +++ b/util/messages.h @@ -4,6 +4,8 @@ * The canonical version of this file is maintained in the rra-c-util package, * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>. * + * Written by Russ Allbery <eagle@eyrie.org> + * Copyright 2015 Russ Allbery <eagle@eyrie.org> * Copyright 2008, 2010, 2013, 2014 * The Board of Trustees of the Leland Stanford Junior University * Copyright (c) 2004, 2005, 2006 diff --git a/util/network.c b/util/network.c index 25b069d..b3dcb30 100644 --- a/util/network.c +++ b/util/network.c @@ -292,7 +292,7 @@ network_bind_all(int type, unsigned short port, socket_type **fds, hints.ai_family = AF_UNSPEC; hints.ai_socktype = type; status = snprintf(service, sizeof(service), "%hu", port); - if (status < 0 || (size_t) status > sizeof(service)) { + if (status < 0 || (size_t) status >= sizeof(service)) { warn("cannot convert port %hu to string", port); socket_set_errno_einval(); return false; @@ -600,7 +600,7 @@ network_connect_host(const char *host, unsigned short port, hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; status = snprintf(portbuf, sizeof(portbuf), "%hu", port); - if (status > 0 && (size_t) status > sizeof(portbuf)) { + if (status > 0 && (size_t) status >= sizeof(portbuf)) { status = -1; socket_set_errno_einval(); } |