summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ts
diff options
context:
space:
mode:
authorop <>2024-08-26 22:01:28 +0000
committerop <>2024-08-26 22:01:28 +0000
commitecaaddb84944c0b5282670c1e6dfd04f3cf35c10 (patch)
treeb4380f19ddfae3ecff8a6134f17a46a472cdd415 /src/lib/libcrypto/ts
parent60298806bf99f206c5f6cfe260a00f54b00e0583 (diff)
downloadopenbsd-ecaaddb84944c0b5282670c1e6dfd04f3cf35c10.tar.gz
openbsd-ecaaddb84944c0b5282670c1e6dfd04f3cf35c10.tar.bz2
openbsd-ecaaddb84944c0b5282670c1e6dfd04f3cf35c10.zip
replace atoi(3) usage with strtonum(3); ok/tweaks tb@
Diffstat (limited to 'src/lib/libcrypto/ts')
-rw-r--r--src/lib/libcrypto/ts/ts_conf.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/lib/libcrypto/ts/ts_conf.c b/src/lib/libcrypto/ts/ts_conf.c
index ef8569ef04..bd499238f5 100644
--- a/src/lib/libcrypto/ts/ts_conf.c
+++ b/src/lib/libcrypto/ts/ts_conf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ts_conf.c,v 1.14 2024/03/26 00:39:22 beck Exp $ */ 1/* $OpenBSD: ts_conf.c,v 1.15 2024/08/26 22:01:28 op 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 */
@@ -56,6 +56,8 @@
56 * 56 *
57 */ 57 */
58 58
59#include <limits.h>
60#include <stdlib.h>
59#include <string.h> 61#include <string.h>
60 62
61#include <openssl/opensslconf.h> 63#include <openssl/opensslconf.h>
@@ -394,6 +396,7 @@ TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx)
394 int secs = 0, millis = 0, micros = 0; 396 int secs = 0, millis = 0, micros = 0;
395 STACK_OF(CONF_VALUE) *list = NULL; 397 STACK_OF(CONF_VALUE) *list = NULL;
396 char *accuracy = NCONF_get_string(conf, section, ENV_ACCURACY); 398 char *accuracy = NCONF_get_string(conf, section, ENV_ACCURACY);
399 const char *errstr;
397 400
398 if (accuracy && !(list = X509V3_parse_list(accuracy))) { 401 if (accuracy && !(list = X509V3_parse_list(accuracy))) {
399 TS_CONF_invalid(section, ENV_ACCURACY); 402 TS_CONF_invalid(section, ENV_ACCURACY);
@@ -402,14 +405,33 @@ TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx)
402 for (i = 0; i < sk_CONF_VALUE_num(list); ++i) { 405 for (i = 0; i < sk_CONF_VALUE_num(list); ++i) {
403 CONF_VALUE *val = sk_CONF_VALUE_value(list, i); 406 CONF_VALUE *val = sk_CONF_VALUE_value(list, i);
404 if (strcmp(val->name, ENV_VALUE_SECS) == 0) { 407 if (strcmp(val->name, ENV_VALUE_SECS) == 0) {
405 if (val->value) 408 if (val->value) {
406 secs = atoi(val->value); 409 secs = strtonum(val->value, 0, INT_MAX,
410 &errstr);
411 if (errstr != NULL) {
412 TS_CONF_invalid(section,
413 ENV_VALUE_SECS);
414 goto err;
415 }
416 }
407 } else if (strcmp(val->name, ENV_VALUE_MILLISECS) == 0) { 417 } else if (strcmp(val->name, ENV_VALUE_MILLISECS) == 0) {
408 if (val->value) 418 if (val->value) {
409 millis = atoi(val->value); 419 millis = strtonum(val->value, 1, 999, &errstr);
420 if (errstr != NULL) {
421 TS_CONF_invalid(section,
422 ENV_VALUE_MILLISECS);
423 goto err;
424 }
425 }
410 } else if (strcmp(val->name, ENV_VALUE_MICROSECS) == 0) { 426 } else if (strcmp(val->name, ENV_VALUE_MICROSECS) == 0) {
411 if (val->value) 427 if (val->value) {
412 micros = atoi(val->value); 428 micros = strtonum(val->value, 1, 999, &errstr);
429 if (errstr != NULL) {
430 TS_CONF_invalid(section,
431 ENV_VALUE_MICROSECS);
432 goto err;
433 }
434 }
413 } else { 435 } else {
414 TS_CONF_invalid(section, ENV_ACCURACY); 436 TS_CONF_invalid(section, ENV_ACCURACY);
415 goto err; 437 goto err;