Page MenuHomeFreeBSD

sh: Avoid referencing uninitialized memory in alias
ClosedPublic

Authored by jrm on May 15 2025, 3:13 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jul 4, 6:56 PM
Unknown Object (File)
Fri, Jul 3, 8:26 AM
Unknown Object (File)
Tue, Jun 23, 7:27 AM
Unknown Object (File)
Sat, Jun 20, 9:09 AM
Unknown Object (File)
May 18 2026, 4:16 PM
Unknown Object (File)
May 17 2026, 8:37 AM
Unknown Object (File)
May 16 2026, 11:21 PM
Unknown Object (File)
May 16 2026, 8:25 PM
Subscribers

Details

Summary

If run as
alias ''
uninitialized memory could be referenced.

This is based on a fix from NetBSD. For more information, refer to the
commit log in
https://github.com/NetBSD/src/commit/10cfed82c282ff96a5a8818a9ce9b0e7444d418d

Obtained from: NetBSD (kre)
MFC after: 3 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jrm requested review of this revision.May 15 2025, 3:13 PM

Heh,

$ /bin/sh
$ alias '' ==
$ alias
Bus error (core dumped)
$ 
This revision is now accepted and ready to land.May 15 2025, 3:40 PM
emaste requested changes to this revision.May 15 2025, 3:45 PM
emaste added inline comments.
bin/sh/alias.c
208

n is by definition an empty string, so the message would be alias: : not found which is confusing

This revision now requires changes to proceed.May 15 2025, 3:45 PM
This revision is now accepted and ready to land.May 16 2025, 1:57 PM