From 15e0442b8cfbbc095af4db97db7cd2b6d8dc23d0 Mon Sep 17 00:00:00 2001 From: guenther <> Date: Sat, 19 Apr 2014 11:46:39 +0000 Subject: We'll interpret a (void) cast on snprintf() to mean it's been verified that truncation is either desirable, not an issue, or is detected and handled later ok deraadt@ --- src/lib/libcrypto/bio/b_dump.c | 8 ++++---- src/lib/libcrypto/bio/b_sock.c | 4 ++-- src/lib/libcrypto/bio/bio_cb.c | 30 +++++++++++++++--------------- src/lib/libcrypto/bio/bss_conn.c | 4 ++-- 4 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src/lib/libcrypto/bio') diff --git a/src/lib/libcrypto/bio/b_dump.c b/src/lib/libcrypto/bio/b_dump.c index 61c9fe20a3..740686c957 100644 --- a/src/lib/libcrypto/bio/b_dump.c +++ b/src/lib/libcrypto/bio/b_dump.c @@ -108,14 +108,14 @@ BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), for (i = 0; i < rows; i++) { buf[0] = '\0'; /* start with empty string */ strlcpy(buf, str, sizeof buf); - (void) snprintf(tmp, sizeof tmp, "%04x - ", i*dump_width); + snprintf(tmp, sizeof tmp, "%04x - ", i*dump_width); strlcat(buf, tmp, sizeof buf); for (j = 0; j < dump_width; j++) { if (((i*dump_width) + j) >= len) { strlcat(buf, " ", sizeof buf); } else { ch = ((unsigned char)*(s + i*dump_width + j)) & 0xff; - (void) snprintf(tmp, sizeof tmp, "%02x%c", ch, + snprintf(tmp, sizeof tmp, "%02x%c", ch, j == 7 ? '-' : ' '); strlcat(buf, tmp, sizeof buf); } @@ -125,7 +125,7 @@ BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), if (((i*dump_width) + j) >= len) break; ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff; - (void) snprintf(tmp, sizeof tmp, "%c", + snprintf(tmp, sizeof tmp, "%c", ((ch >= ' ') && (ch <= '~')) ? ch : '.'); strlcat(buf, tmp, sizeof buf); } @@ -137,7 +137,7 @@ BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), } #ifdef TRUNCATE if (trc > 0) { - (void) snprintf(buf, sizeof buf, "%s%04x - \n", + snprintf(buf, sizeof buf, "%s%04x - \n", str, len + trc); ret += cb((void *)buf, strlen(buf), u); } diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c index a82c79a1b0..a6dd43f397 100644 --- a/src/lib/libcrypto/bio/b_sock.c +++ b/src/lib/libcrypto/bio/b_sock.c @@ -543,7 +543,7 @@ BIO_accept(int sock, char **addr) goto end; } *addr = p; - (void) snprintf(*addr, nl, "%s:%s", h, s); + snprintf(*addr, nl, "%s:%s", h, s); goto end; } while (0); #endif @@ -558,7 +558,7 @@ BIO_accept(int sock, char **addr) } *addr = p; } - (void) snprintf(*addr, 24, "%d.%d.%d.%d:%d", + snprintf(*addr, 24, "%d.%d.%d.%d:%d", (unsigned char)(l >> 24L) & 0xff, (unsigned char)(l >> 16L) & 0xff, (unsigned char)(l >> 8L) & 0xff, (unsigned char)(l) & 0xff, port); diff --git a/src/lib/libcrypto/bio/bio_cb.c b/src/lib/libcrypto/bio/bio_cb.c index a272bf969a..133d2b77dc 100644 --- a/src/lib/libcrypto/bio/bio_cb.c +++ b/src/lib/libcrypto/bio/bio_cb.c @@ -76,62 +76,62 @@ BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi, long argl, if (BIO_CB_RETURN & cmd) r = ret; - (void) snprintf(buf, sizeof buf, "BIO[%08lX]:", (unsigned long)bio); + snprintf(buf, sizeof buf, "BIO[%08lX]:", (unsigned long)bio); p = &(buf[14]); p_maxlen = sizeof buf - 14; switch (cmd) { case BIO_CB_FREE: - (void) snprintf(p, p_maxlen, "Free - %s\n", bio->method->name); + snprintf(p, p_maxlen, "Free - %s\n", bio->method->name); break; case BIO_CB_READ: if (bio->method->type & BIO_TYPE_DESCRIPTOR) - (void) snprintf(p, p_maxlen, + snprintf(p, p_maxlen, "read(%d,%lu) - %s fd=%d\n", bio->num, (unsigned long)argi, bio->method->name, bio->num); else - (void) snprintf(p, p_maxlen, "read(%d,%lu) - %s\n", + snprintf(p, p_maxlen, "read(%d,%lu) - %s\n", bio->num, (unsigned long)argi, bio->method->name); break; case BIO_CB_WRITE: if (bio->method->type & BIO_TYPE_DESCRIPTOR) - (void) snprintf(p, p_maxlen, + snprintf(p, p_maxlen, "write(%d,%lu) - %s fd=%d\n", bio->num, (unsigned long)argi, bio->method->name, bio->num); else - (void) snprintf(p, p_maxlen, "write(%d,%lu) - %s\n", + snprintf(p, p_maxlen, "write(%d,%lu) - %s\n", bio->num, (unsigned long)argi, bio->method->name); break; case BIO_CB_PUTS: - (void) snprintf(p, p_maxlen, + snprintf(p, p_maxlen, "puts() - %s\n", bio->method->name); break; case BIO_CB_GETS: - (void) snprintf(p, p_maxlen, "gets(%lu) - %s\n", + snprintf(p, p_maxlen, "gets(%lu) - %s\n", (unsigned long)argi, bio->method->name); break; case BIO_CB_CTRL: - (void) snprintf(p, p_maxlen, "ctrl(%lu) - %s\n", + snprintf(p, p_maxlen, "ctrl(%lu) - %s\n", (unsigned long)argi, bio->method->name); break; case BIO_CB_RETURN|BIO_CB_READ: - (void) snprintf(p, p_maxlen, "read return %ld\n", ret); + snprintf(p, p_maxlen, "read return %ld\n", ret); break; case BIO_CB_RETURN|BIO_CB_WRITE: - (void) snprintf(p, p_maxlen, "write return %ld\n", ret); + snprintf(p, p_maxlen, "write return %ld\n", ret); break; case BIO_CB_RETURN|BIO_CB_GETS: - (void) snprintf(p, p_maxlen, "gets return %ld\n", ret); + snprintf(p, p_maxlen, "gets return %ld\n", ret); break; case BIO_CB_RETURN|BIO_CB_PUTS: - (void) snprintf(p, p_maxlen, "puts return %ld\n", ret); + snprintf(p, p_maxlen, "puts return %ld\n", ret); break; case BIO_CB_RETURN|BIO_CB_CTRL: - (void) snprintf(p, p_maxlen, "ctrl return %ld\n", ret); + snprintf(p, p_maxlen, "ctrl return %ld\n", ret); break; default: - (void) snprintf(p, p_maxlen, + snprintf(p, p_maxlen, "bio callback - unknown type (%d)\n", cmd); break; } diff --git a/src/lib/libcrypto/bio/bss_conn.c b/src/lib/libcrypto/bio/bss_conn.c index fca5d5e853..45815fd696 100644 --- a/src/lib/libcrypto/bio/bss_conn.c +++ b/src/lib/libcrypto/bio/bss_conn.c @@ -482,7 +482,7 @@ conn_ctrl(BIO *b, int cmd, long num, void *ptr) char buf[16]; unsigned char *p = ptr; - (void) snprintf(buf, sizeof buf, "%d.%d.%d.%d", + snprintf(buf, sizeof buf, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); if (data->param_hostname != NULL) free(data->param_hostname); @@ -491,7 +491,7 @@ conn_ctrl(BIO *b, int cmd, long num, void *ptr) } else if (num == 3) { char buf[DECIMAL_SIZE(int) + 1]; - (void) snprintf(buf, sizeof buf, "%d", + snprintf(buf, sizeof buf, "%d", *(int *)ptr); if (data->param_port != NULL) free(data->param_port); -- cgit v1.2.3-55-g6feb