`getpwuid_r`s semantics is a bit tricky: normally it returns 0 and sets
the output parameter (struct passwd **result) accordingly. If no
matching password record was found, it returns 0 and `*result` is set
to NULL. In case of error, an error number is returned, but the
`*result` is also set to NULL. Since for the API client the reason does
not matter, not checking the return value from the `getpwuid_r` syscall
is not an issue (we're returning `SUBSESSION_ERROR_IO_ERROR` in both
cases). However, to satisfy static analysers we have, it's not
necessarily a bad idea to perform an explicit return value check.
Change-Id: Iefaeccd09331cff977b7cc2a449367de7d5c7db1
return SUBSESSION_ERROR_OUT_OF_MEMORY;
struct passwd pass_buf, *pass_ptr;
- getpwuid_r(session_uid, &pass_buf, pw_buf, max_buf_len, &pass_ptr);
+ if (getpwuid_r(session_uid, &pass_buf, pw_buf, max_buf_len, &pass_ptr) != 0)
+ return SUBSESSION_ERROR_IO_ERROR;
if (!pass_ptr)
return SUBSESSION_ERROR_IO_ERROR;