Skip to content

htdbm: Fix NULL pointer dereferences on conflicting options (PR 69404) [2.4.x] - #1051

Open
arturobernalg wants to merge 1 commit into
apache:2.4.xfrom
arturobernalg:backport/bz69404-htdbm-null-deref-24x
Open

arturobernalg wants to merge 1 commit into
apache:2.4.xfrom
arturobernalg:backport/bz69404-htdbm-null-deref-24x

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

Backport of #912 (trunk e3d134d) to 2.4.x. BZ 69404.

htdbm crashed with SIGSEGV when "-n" or "-l" was combined with "-v", "-x" or each other, in any order. main() now rejects these combinations as a usage error (exit 2) before any prompt or database open, and "-l" reports database read failures with a non-zero exit.

Clean cherry-pick (-x), no changes needed for 2.4.x.

Tested on a real 2.4.x build with test/modules/core/test_014_htdbm_null_deref.py:
[x] fix applied: 15 passed
[x] support/htdbm.c reverted to 2.4.x: 10 failed (the conflicting combinations, e.g. "-n -v" exits 139/SIGSEGV), 5 passed (positive controls)
[x] modules/core suite: 271 passed; the only errors were AH01254 (cgid ScriptSock path too long in my local scratch dir), unrelated

htdbm: Fix NULL pointer dereferences on conflicting options.

"-l" (list) does not need or consume a username, and "-n" (print the
hash, no database file) never opens a database, but "-v" (verify),
"-x" (delete) and "-l" itself all need a username and/or an open
database. Combining them crashed with SIGSEGV deep inside htdbm_del(),
htdbm_verify() or htdbm_list(), regardless of option order.

Reject these combinations where they are parsed, in main(), before
any password prompt, database open or positional argument is
consumed, instead of patching each helper with its own NULL guard:
that approach left two cases reaching a helper's "nothing to do"
return path undetected by its caller, so "-n -l" exited 0 having
done nothing, and "-l -x" against an existing database printed
"Cannot find user '(null)' in database" from a NULL username passed
to fprintf("%s"). Also make the HTDBM_LIST dispatch in main() check
htdbm_list()'s return value, so a genuine read failure no longer
exits 0 like a successful listing does.

PR 69404

(cherry picked from commit e3d134d)
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.

1 participant