passwd: initialize pointers correctly
authorEinar Jón <tolvupostur@gmail.com>
Tue, 8 Jan 2019 15:31:37 +0000 (16:31 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 8 Jan 2019 15:32:25 +0000 (16:32 +0100)
commitce51140664d82300d25b096b4a41f01fdfd766b3
tree95b02b340288d67e5fa10f4608066e9eed2354de
parent959b04bc0e9d23daa51f75130c7d3eeacd91e52c
passwd: initialize pointers correctly

Fix for running passwd as root (or sudo passwd $USER).
Crashed on call to free(orig) during cleanup.

Fix regression from commit 17058a06c4333fc0c492c168c8a971ebd0fd5a5a
Root user never changes the orig pointer, so when cleaning up, passwd tried to
free orig=(char*)""
Example: sudo passwd $USER
Changing password for xxx
New password:
Bad password: too short
Retype password:
Passwords don't match
free(): invalid pointer
Aborted

function                                             old     new   delta
passwd_main                                          958     961      +3

Signed-off-by: Einar Jón <tolvupostur@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
loginutils/passwd.c