Skip to content

Commit 3de0892

Browse files
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 <admardare@gmail.com>
1 parent e6b1f8c commit 3de0892

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

lib/dialects/linux/dproc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,7 @@ static int process_id(struct lsof_context *ctx, /* context */
11841184
continue;
11851185
(void)make_proc_path(ctx, dpath, i, &path, &pathl, fp->d_name);
11861186
(void)alloc_lfile(ctx, LSOF_FD_NUMERIC, fd);
1187+
efs = 0;
11871188
if (getlinksrc(path, pbuf, sizeof(pbuf), &rest) < 1) {
11881189
zeromem((char *)&sb, sizeof(sb));
11891190
lnk = ss = 0;

0 commit comments

Comments
 (0)