Skip to content

reject an empty entry in the -u list - #377

Merged
jiegec merged 2 commits into
lsof-org:masterfrom
Ar-maan05:uid-empty-entry
Nov 3, 2026
Merged

jiegec merged 2 commits into
lsof-org:masterfrom
Ar-maan05:uid-empty-entry

Conversation

@Ar-maan05

Copy link
Copy Markdown
Contributor

lsof -u ,99999 lists root's files:

before: 1352 lines for root
after:  lsof: empty -u UID or login name: ,99999

the empty first entry goes through enter_uid() with nothing parsed, so the uid stays 0. a lone -u ^ excludes root the same way. easy to hit from a script that builds the list with a leading comma.

added case-20-uid-empty-entry.bash for both forms, it fails before and passes after. make check is clean.

an empty entry like the first one in "-u ,99999", or a lone "^", was parsed as UID 0, so lsof listed or excluded root's files. report an error instead.
Comment thread src/arg.c
}
}
}
return (err);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe check if empty list here? For e.g. -u "".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, -u "" was just listing everything. it now errors out with "no UIDs specified" like a missing argument, and added it to the test

-u "" was accepted with no UIDs at all, so lsof just listed evrything, root's files included. treat it like a missing argument and report "no UIDs specified".
@jiegec
jiegec merged commit 3f2dd98 into lsof-org:master Nov 3, 2026
17 checks passed
@Ar-maan05
Ar-maan05 deleted the uid-empty-entry branch November 3, 2026 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants