From 3de08929fdb3a3a252f13d584aa80f0919126fe8 Mon Sep 17 00:00:00 2001 From: Adrian Mardare Date: Tue, 26 Aug 2025 18:44:08 -0400 Subject: [PATCH] Fix null pointer exception The logic in process_id() requires a reset of the efs variable on every iteration through the while ((fp = readdir(fdp)) loop. Failure to do that can land us in a situation where efs=1 from a previous iteration and pn=1 from the current iteration. Signed-off-by: Adrian Mardare --- lib/dialects/linux/dproc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/dialects/linux/dproc.c b/lib/dialects/linux/dproc.c index b4bb9947..8dc7c27a 100644 --- a/lib/dialects/linux/dproc.c +++ b/lib/dialects/linux/dproc.c @@ -1184,6 +1184,7 @@ static int process_id(struct lsof_context *ctx, /* context */ continue; (void)make_proc_path(ctx, dpath, i, &path, &pathl, fp->d_name); (void)alloc_lfile(ctx, LSOF_FD_NUMERIC, fd); + efs = 0; if (getlinksrc(path, pbuf, sizeof(pbuf), &rest) < 1) { zeromem((char *)&sb, sizeof(sb)); lnk = ss = 0;