From: Masatake YAMATO Date: Thu, 3 Oct 2024 06:17:01 +0000 (+0900) Subject: lsfd: avoid accessing an uninitialized value X-Git-Tag: v2.42-start~186^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ea0a1076181f27af39a0653f08fbc705e2b784ce;p=thirdparty%2Futil-linux.git lsfd: avoid accessing an uninitialized value sb, a local variable in collect_file_symlink, accessed at bool is_socket = (sb.st_mode & S_IFMT) == S_IFSOCK; was not initialized if copy_file path is taken. Signed-off-by: Masatake YAMATO --- diff --git a/lsfd-cmd/lsfd.c b/lsfd-cmd/lsfd.c index 6b93016d9..09ef9a588 100644 --- a/lsfd-cmd/lsfd.c +++ b/lsfd-cmd/lsfd.c @@ -849,9 +849,10 @@ static struct file *collect_file_symlink(struct path_cxt *pc, */ else if ((prev = list_last_entry(&proc->files, struct file, files)) && (!prev->is_error) - && prev->name && strcmp(prev->name, sym) == 0) + && prev->name && strcmp(prev->name, sym) == 0) { f = copy_file(prev, assoc); - else if (ul_path_stat(pc, &sb, 0, name) < 0) + sb = prev->stat; + } else if (ul_path_stat(pc, &sb, 0, name) < 0) f = new_stat_error_file(proc, sym, errno, assoc); else { const struct file_class *class = stat2class(&sb);