]> git.ipfire.org Git - thirdparty/shadow.git/commit
chfn: Prevent buffer overflow. 268/head
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 12 Jul 2020 17:01:52 +0000 (19:01 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 12 Jul 2020 17:09:14 +0000 (19:09 +0200)
commit875d2d49c1a5143da312ea18ed78486b4e25a78d
tree21b5c4b0e0fd209363a099ca308c1c33ba6e586c
parent607f1dd549cf9abc87af1cf29275f0d2d11eea29
chfn: Prevent buffer overflow.

This is a stability fix, not a security fix, because the affected -o
option can only be used by root and it takes a modified passwd file.

If a gecos field for a user has BUFSIZ characters without commas and an
equals sign (i.e. a huge slop/extra field) and chfn is called with -o,
then a buffer overflow occurs.

It is not possible to trigger this with shadow tools. Therefore, the
passwd file must be modified manually.

I have fixed this unlikely case the easiest and cleanest way possible.
Since chfn bails out if more than 80 characters excluding commas are
supposed to be written into gecos field, we can stop processing early on
if -o argument is too long.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
src/chfn.c