e ckpasswd - handle read errors on stdin

error path - not going to be a problem but in theory... it's there.

fix CID 1425211
This commit is contained in:
Carsten Haitzler 2020-04-19 01:58:44 +01:00
parent 23493550b2
commit 2ccfec3dad
1 changed files with 10 additions and 0 deletions

View File

@ -296,6 +296,11 @@ main(int argc, char **argv)
for (;;) // cookie for (;;) // cookie
{ {
rd = read(0, pw + pos, 1); rd = read(0, pw + pos, 1);
if (rd < 0)
{
fprintf(stderr, "Error. Can't read polkit cookie on stdin\n");
goto err;
}
if (pw[pos] == ' ') if (pw[pos] == ' ')
{ {
memcpy(polkit_cookie, pw, pos); memcpy(polkit_cookie, pw, pos);
@ -317,6 +322,11 @@ main(int argc, char **argv)
for (;;) // uid for (;;) // uid
{ {
rd = read(0, pw + pos, 1); rd = read(0, pw + pos, 1);
if (rd < 0)
{
fprintf(stderr, "Error. Can't read polkit uid on stdin\n");
goto err;
}
if (pw[pos] == ' ') if (pw[pos] == ' ')
{ {
pw[pos] = 0; pw[pos] = 0;