diff options
author | deraadt <> | 2019-07-03 03:24:04 +0000 |
---|---|---|
committer | deraadt <> | 2019-07-03 03:24:04 +0000 |
commit | ef84a12d8fc3f2dacb57102d5f84bfb4025a320a (patch) | |
tree | 095ed8468464d046dbf7618376c0a18af76dceba | |
parent | 88ab3711341dea97a3118b0654ceab1679d5e0a1 (diff) | |
download | openbsd-ef84a12d8fc3f2dacb57102d5f84bfb4025a320a.tar.gz openbsd-ef84a12d8fc3f2dacb57102d5f84bfb4025a320a.tar.bz2 openbsd-ef84a12d8fc3f2dacb57102d5f84bfb4025a320a.zip |
snprintf/vsnprintf return < 0 on error, rather than -1.
-rw-r--r-- | src/lib/libc/net/inet_net_ntop.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/objects/obj_dat.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/ts/ts_rsp_sign.c | 4 | ||||
-rw-r--r-- | src/usr.bin/nc/socks.c | 6 | ||||
-rw-r--r-- | src/usr.bin/openssl/apps.c | 4 | ||||
-rw-r--r-- | src/usr.bin/openssl/ca.c | 4 | ||||
-rw-r--r-- | src/usr.bin/openssl/req.c | 18 | ||||
-rw-r--r-- | src/usr.bin/openssl/s_time.c | 4 |
8 files changed, 25 insertions, 25 deletions
diff --git a/src/lib/libc/net/inet_net_ntop.c b/src/lib/libc/net/inet_net_ntop.c index 652b24076e..1f1c4bed12 100644 --- a/src/lib/libc/net/inet_net_ntop.c +++ b/src/lib/libc/net/inet_net_ntop.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: inet_net_ntop.c,v 1.8 2015/05/14 11:52:43 jsg Exp $ */ | 1 | /* $OpenBSD: inet_net_ntop.c,v 1.9 2019/07/03 03:24:04 deraadt Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2012 by Gilles Chehade <gilles@openbsd.org> | 4 | * Copyright (c) 2012 by Gilles Chehade <gilles@openbsd.org> |
@@ -151,7 +151,7 @@ inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) | |||
151 | return (NULL); | 151 | return (NULL); |
152 | 152 | ||
153 | ret = snprintf(dst, size, "%s/%d", buf, bits); | 153 | ret = snprintf(dst, size, "%s/%d", buf, bits); |
154 | if (ret == -1 || ret >= size) { | 154 | if (ret < 0 || ret >= size) { |
155 | errno = EMSGSIZE; | 155 | errno = EMSGSIZE; |
156 | return (NULL); | 156 | return (NULL); |
157 | } | 157 | } |
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c index 6c50aa980a..c0b63e4d85 100644 --- a/src/lib/libcrypto/objects/obj_dat.c +++ b/src/lib/libcrypto/objects/obj_dat.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: obj_dat.c,v 1.41 2018/09/08 13:49:26 tb Exp $ */ | 1 | /* $OpenBSD: obj_dat.c,v 1.42 2019/07/03 03:24:04 deraadt Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -608,7 +608,7 @@ OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name) | |||
608 | goto err; | 608 | goto err; |
609 | i = snprintf(buf, buf_len, ".%s", bndec); | 609 | i = snprintf(buf, buf_len, ".%s", bndec); |
610 | free(bndec); | 610 | free(bndec); |
611 | if (i == -1) | 611 | if (i < 0) |
612 | goto err; | 612 | goto err; |
613 | if (i >= buf_len) { | 613 | if (i >= buf_len) { |
614 | buf_len = 0; | 614 | buf_len = 0; |
@@ -619,7 +619,7 @@ OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name) | |||
619 | ret += i; | 619 | ret += i; |
620 | } else { | 620 | } else { |
621 | i = snprintf(buf, buf_len, ".%lu", l); | 621 | i = snprintf(buf, buf_len, ".%lu", l); |
622 | if (i == -1) | 622 | if (i < 0) |
623 | goto err; | 623 | goto err; |
624 | if (i >= buf_len) { | 624 | if (i >= buf_len) { |
625 | buf_len = 0; | 625 | buf_len = 0; |
diff --git a/src/lib/libcrypto/ts/ts_rsp_sign.c b/src/lib/libcrypto/ts/ts_rsp_sign.c index 9ab80160b3..6125fdd4be 100644 --- a/src/lib/libcrypto/ts/ts_rsp_sign.c +++ b/src/lib/libcrypto/ts/ts_rsp_sign.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ts_rsp_sign.c,v 1.22 2018/05/13 15:04:05 tb Exp $ */ | 1 | /* $OpenBSD: ts_rsp_sign.c,v 1.23 2019/07/03 03:24:04 deraadt Exp $ */ |
2 | /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL | 2 | /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL |
3 | * project 2002. | 3 | * project 2002. |
4 | */ | 4 | */ |
@@ -1001,7 +1001,7 @@ TS_RESP_set_genTime_with_precision(ASN1_GENERALIZEDTIME *asn1_time, | |||
1001 | "%04d%02d%02d%02d%02d%02d%sZ", | 1001 | "%04d%02d%02d%02d%02d%02d%sZ", |
1002 | tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, | 1002 | tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, |
1003 | tm->tm_hour, tm->tm_min, tm->tm_sec, usecstr); | 1003 | tm->tm_hour, tm->tm_min, tm->tm_sec, usecstr); |
1004 | if (rv == -1 || rv >= sizeof(genTime_str)) | 1004 | if (rv < 0 || rv >= sizeof(genTime_str)) |
1005 | goto err; | 1005 | goto err; |
1006 | 1006 | ||
1007 | /* Now call OpenSSL to check and set our genTime value */ | 1007 | /* Now call OpenSSL to check and set our genTime value */ |
diff --git a/src/usr.bin/nc/socks.c b/src/usr.bin/nc/socks.c index 856c3e7446..39e4331be3 100644 --- a/src/usr.bin/nc/socks.c +++ b/src/usr.bin/nc/socks.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: socks.c,v 1.27 2019/01/10 12:44:54 mestre Exp $ */ | 1 | /* $OpenBSD: socks.c,v 1.28 2019/07/03 03:24:02 deraadt Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1999 Niklas Hallqvist. All rights reserved. | 4 | * Copyright (c) 1999 Niklas Hallqvist. All rights reserved. |
@@ -334,7 +334,7 @@ socks_connect(const char *host, const char *port, | |||
334 | "CONNECT %s:%d HTTP/1.0\r\n", | 334 | "CONNECT %s:%d HTTP/1.0\r\n", |
335 | host, ntohs(serverport)); | 335 | host, ntohs(serverport)); |
336 | } | 336 | } |
337 | if (r == -1 || (size_t)r >= sizeof(buf)) | 337 | if (r < 0 || (size_t)r >= sizeof(buf)) |
338 | errx(1, "hostname too long"); | 338 | errx(1, "hostname too long"); |
339 | r = strlen(buf); | 339 | r = strlen(buf); |
340 | 340 | ||
@@ -357,7 +357,7 @@ socks_connect(const char *host, const char *port, | |||
357 | errx(1, "Proxy username/password too long"); | 357 | errx(1, "Proxy username/password too long"); |
358 | r = snprintf(buf, sizeof(buf), "Proxy-Authorization: " | 358 | r = snprintf(buf, sizeof(buf), "Proxy-Authorization: " |
359 | "Basic %s\r\n", resp); | 359 | "Basic %s\r\n", resp); |
360 | if (r == -1 || (size_t)r >= sizeof(buf)) | 360 | if (r < 0 || (size_t)r >= sizeof(buf)) |
361 | errx(1, "Proxy auth response too long"); | 361 | errx(1, "Proxy auth response too long"); |
362 | r = strlen(buf); | 362 | r = strlen(buf); |
363 | if ((cnt = atomicio(vwrite, proxyfd, buf, r)) != r) | 363 | if ((cnt = atomicio(vwrite, proxyfd, buf, r)) != r) |
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c index 47e21265af..39ce7a5f34 100644 --- a/src/usr.bin/openssl/apps.c +++ b/src/usr.bin/openssl/apps.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: apps.c,v 1.52 2019/06/28 13:35:02 deraadt Exp $ */ | 1 | /* $OpenBSD: apps.c,v 1.53 2019/07/03 03:24:02 deraadt Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -1328,7 +1328,7 @@ save_serial(char *serialfile, char *suffix, BIGNUM *serial, | |||
1328 | else | 1328 | else |
1329 | n = snprintf(serialpath, sizeof serialpath, "%s.%s", | 1329 | n = snprintf(serialpath, sizeof serialpath, "%s.%s", |
1330 | serialfile, suffix); | 1330 | serialfile, suffix); |
1331 | if (n == -1 || n >= sizeof(serialpath)) { | 1331 | if (n < 0 || n >= sizeof(serialpath)) { |
1332 | BIO_printf(bio_err, "serial too long\n"); | 1332 | BIO_printf(bio_err, "serial too long\n"); |
1333 | goto err; | 1333 | goto err; |
1334 | } | 1334 | } |
diff --git a/src/usr.bin/openssl/ca.c b/src/usr.bin/openssl/ca.c index 2e79849572..ac183f28bf 100644 --- a/src/usr.bin/openssl/ca.c +++ b/src/usr.bin/openssl/ca.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ca.c,v 1.26 2018/02/07 05:47:55 jsing Exp $ */ | 1 | /* $OpenBSD: ca.c,v 1.27 2019/07/03 03:24:02 deraadt Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -1109,7 +1109,7 @@ ca_main(int argc, char **argv) | |||
1109 | k = snprintf(pempath, sizeof(pempath), | 1109 | k = snprintf(pempath, sizeof(pempath), |
1110 | "%s/%s.pem", outdir, serialstr); | 1110 | "%s/%s.pem", outdir, serialstr); |
1111 | free(serialstr); | 1111 | free(serialstr); |
1112 | if (k == -1 || k >= sizeof(pempath)) { | 1112 | if (k < 0 || k >= sizeof(pempath)) { |
1113 | BIO_printf(bio_err, | 1113 | BIO_printf(bio_err, |
1114 | "certificate file name too long\n"); | 1114 | "certificate file name too long\n"); |
1115 | goto err; | 1115 | goto err; |
diff --git a/src/usr.bin/openssl/req.c b/src/usr.bin/openssl/req.c index c5cae4df89..6b7dfb98b9 100644 --- a/src/usr.bin/openssl/req.c +++ b/src/usr.bin/openssl/req.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: req.c,v 1.15 2018/02/07 05:47:55 jsing Exp $ */ | 1 | /* $OpenBSD: req.c,v 1.16 2019/07/03 03:24:02 deraadt Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -1030,7 +1030,7 @@ prompt_info(X509_REQ * req, | |||
1030 | if ((nid = OBJ_txt2nid(type)) == NID_undef) | 1030 | if ((nid = OBJ_txt2nid(type)) == NID_undef) |
1031 | goto start; | 1031 | goto start; |
1032 | ret = snprintf(buf, sizeof buf, "%s_default", v->name); | 1032 | ret = snprintf(buf, sizeof buf, "%s_default", v->name); |
1033 | if (ret == -1 || ret >= sizeof(buf)) { | 1033 | if (ret < 0 || ret >= sizeof(buf)) { |
1034 | BIO_printf(bio_err, "Name '%s' too long for default\n", | 1034 | BIO_printf(bio_err, "Name '%s' too long for default\n", |
1035 | v->name); | 1035 | v->name); |
1036 | return 0; | 1036 | return 0; |
@@ -1040,7 +1040,7 @@ prompt_info(X509_REQ * req, | |||
1040 | def = ""; | 1040 | def = ""; |
1041 | } | 1041 | } |
1042 | ret = snprintf(buf, sizeof buf, "%s_value", v->name); | 1042 | ret = snprintf(buf, sizeof buf, "%s_value", v->name); |
1043 | if (ret == -1 || ret >= sizeof(buf)) { | 1043 | if (ret < 0 || ret >= sizeof(buf)) { |
1044 | BIO_printf(bio_err, "Name '%s' too long for value\n", | 1044 | BIO_printf(bio_err, "Name '%s' too long for value\n", |
1045 | v->name); | 1045 | v->name); |
1046 | return 0; | 1046 | return 0; |
@@ -1050,7 +1050,7 @@ prompt_info(X509_REQ * req, | |||
1050 | value = NULL; | 1050 | value = NULL; |
1051 | } | 1051 | } |
1052 | ret = snprintf(buf, sizeof buf, "%s_min", v->name); | 1052 | ret = snprintf(buf, sizeof buf, "%s_min", v->name); |
1053 | if (ret == -1 || ret >= sizeof(buf)) { | 1053 | if (ret < 0 || ret >= sizeof(buf)) { |
1054 | BIO_printf(bio_err, "Name '%s' too long for min\n", | 1054 | BIO_printf(bio_err, "Name '%s' too long for min\n", |
1055 | v->name); | 1055 | v->name); |
1056 | return 0; | 1056 | return 0; |
@@ -1060,7 +1060,7 @@ prompt_info(X509_REQ * req, | |||
1060 | n_min = -1; | 1060 | n_min = -1; |
1061 | } | 1061 | } |
1062 | ret = snprintf(buf, sizeof buf, "%s_max", v->name); | 1062 | ret = snprintf(buf, sizeof buf, "%s_max", v->name); |
1063 | if (ret == -1 || ret >= sizeof(buf)) { | 1063 | if (ret < 0 || ret >= sizeof(buf)) { |
1064 | BIO_printf(bio_err, "Name '%s' too long for max\n", | 1064 | BIO_printf(bio_err, "Name '%s' too long for max\n", |
1065 | v->name); | 1065 | v->name); |
1066 | return 0; | 1066 | return 0; |
@@ -1098,7 +1098,7 @@ start2: for (;;) { | |||
1098 | if ((nid = OBJ_txt2nid(type)) == NID_undef) | 1098 | if ((nid = OBJ_txt2nid(type)) == NID_undef) |
1099 | goto start2; | 1099 | goto start2; |
1100 | ret = snprintf(buf, sizeof buf, "%s_default", type); | 1100 | ret = snprintf(buf, sizeof buf, "%s_default", type); |
1101 | if (ret == -1 || ret >= sizeof(buf)) { | 1101 | if (ret < 0 || ret >= sizeof(buf)) { |
1102 | BIO_printf(bio_err, "Name '%s' too long for default\n", | 1102 | BIO_printf(bio_err, "Name '%s' too long for default\n", |
1103 | v->name); | 1103 | v->name); |
1104 | return 0; | 1104 | return 0; |
@@ -1109,7 +1109,7 @@ start2: for (;;) { | |||
1109 | def = ""; | 1109 | def = ""; |
1110 | } | 1110 | } |
1111 | ret = snprintf(buf, sizeof buf, "%s_value", type); | 1111 | ret = snprintf(buf, sizeof buf, "%s_value", type); |
1112 | if (ret == -1 || ret >= sizeof(buf)) { | 1112 | if (ret < 0 || ret >= sizeof(buf)) { |
1113 | BIO_printf(bio_err, "Name '%s' too long for value\n", | 1113 | BIO_printf(bio_err, "Name '%s' too long for value\n", |
1114 | v->name); | 1114 | v->name); |
1115 | return 0; | 1115 | return 0; |
@@ -1120,7 +1120,7 @@ start2: for (;;) { | |||
1120 | value = NULL; | 1120 | value = NULL; |
1121 | } | 1121 | } |
1122 | ret = snprintf(buf, sizeof buf, "%s_min", type); | 1122 | ret = snprintf(buf, sizeof buf, "%s_min", type); |
1123 | if (ret == -1 || ret >= sizeof(buf)) { | 1123 | if (ret < 0 || ret >= sizeof(buf)) { |
1124 | BIO_printf(bio_err, "Name '%s' too long for min\n", | 1124 | BIO_printf(bio_err, "Name '%s' too long for min\n", |
1125 | v->name); | 1125 | v->name); |
1126 | return 0; | 1126 | return 0; |
@@ -1130,7 +1130,7 @@ start2: for (;;) { | |||
1130 | n_min = -1; | 1130 | n_min = -1; |
1131 | } | 1131 | } |
1132 | ret = snprintf(buf, sizeof buf, "%s_max", type); | 1132 | ret = snprintf(buf, sizeof buf, "%s_max", type); |
1133 | if (ret == -1 || ret >= sizeof(buf)) { | 1133 | if (ret < 0 || ret >= sizeof(buf)) { |
1134 | BIO_printf(bio_err, "Name '%s' too long for max\n", | 1134 | BIO_printf(bio_err, "Name '%s' too long for max\n", |
1135 | v->name); | 1135 | v->name); |
1136 | return 0; | 1136 | return 0; |
diff --git a/src/usr.bin/openssl/s_time.c b/src/usr.bin/openssl/s_time.c index 1506ca356a..3263a2dff3 100644 --- a/src/usr.bin/openssl/s_time.c +++ b/src/usr.bin/openssl/s_time.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s_time.c,v 1.32 2018/09/17 15:37:35 cheloha Exp $ */ | 1 | /* $OpenBSD: s_time.c,v 1.33 2019/07/03 03:24:02 deraadt Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -377,7 +377,7 @@ run_test(SSL *scon) | |||
377 | if (s_time_config.www_path != NULL) { | 377 | if (s_time_config.www_path != NULL) { |
378 | retval = snprintf(buf, sizeof buf, | 378 | retval = snprintf(buf, sizeof buf, |
379 | "GET %s HTTP/1.0\r\n\r\n", s_time_config.www_path); | 379 | "GET %s HTTP/1.0\r\n\r\n", s_time_config.www_path); |
380 | if (retval == -1 || retval >= sizeof buf) { | 380 | if (retval < 0 || retval >= sizeof buf) { |
381 | fprintf(stderr, "URL too long\n"); | 381 | fprintf(stderr, "URL too long\n"); |
382 | return 0; | 382 | return 0; |
383 | } | 383 | } |