From 50e08b4bc55d899202982a727787944480ec6247 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Fri, 17 Dec 2021 14:39:35 -0600 Subject: [PATCH] kcm: parse_bytes() returns ssize_t --- kcm/config.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/kcm/config.c b/kcm/config.c index 58d39ef47..be4bce6af 100644 --- a/kcm/config.c +++ b/kcm/config.c @@ -118,6 +118,10 @@ static struct getargs args[] = { "renewable-life", 'r', arg_string, &renew_life, "renewable lifetime of system tickets", "time" }, + { + "max-request", 'r', arg_integer, &max_request_str, + "max request size", "bytes" + }, { "socket-path", 's', arg_string, &socket_path, "path to kcm domain socket", "path" @@ -350,8 +354,15 @@ kcm_configure(int argc, char **argv) krb5_err(kcm_context, 1, ret, "reading configuration files"); } - if(max_request_str) - max_request = parse_bytes(max_request_str, NULL); + if (max_request_str) { + ssize_t bytes; + + if ((bytes = parse_bytes(max_request_str, NULL)) < 0) + krb5_errx(kcm_context, 1, + "--max-request size must be non-negative"); + + max_request = bytes; + } if(max_request == 0){ p = krb5_config_get_string (kcm_context, @@ -359,8 +370,14 @@ kcm_configure(int argc, char **argv) "kcm", "max-request", NULL); - if(p) - max_request = parse_bytes(p, NULL); + if (p) { + ssize_t bytes; + + if ((bytes = parse_bytes(max_request_str, NULL)) < 0) + krb5_errx(kcm_context, 1, + "[kcm] max-request size must be non-negative"); + max_request = bytes; + } } if (system_principal == NULL) {