From: Karel Zak Date: Tue, 23 May 2023 08:43:59 +0000 (+0200) Subject: login: fix memory leak [coverity scan] X-Git-Tag: v2.40-rc1~442 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5e0e06cc2ff05f01a3fcf799a5f2c2fe6fb217f;p=thirdparty%2Futil-linux.git login: fix memory leak [coverity scan] Let's use ul_path_read_buffer() to avoid memory allocation. Signed-off-by: Karel Zak --- diff --git a/login-utils/login.c b/login-utils/login.c index 17b54a7f63..129f3cfa2e 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -1311,13 +1311,12 @@ static void load_credentials(struct login_context *cxt) { } while ((d = xreaddir(dir))) { - char *str; + char str[32] = { 0 }; - if (strcmp(d->d_name, "login.noauth") == 0) { - ul_path_read_string(pc, &str, d->d_name); - if (str && strcmp(str, "yes") == 0) - cxt->noauth = 1; - } + if (strcmp(d->d_name, "login.noauth") == 0 + && ul_path_read_buffer(pc, str, sizeof(str), d->d_name) > 0 + && *str && strcmp(str, "yes") == 0) + cxt->noauth = 1; } }