mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 00:47:10 +09:00
machine: also clean up gid_map fscanf error handling
This commit is contained in:
@@ -659,7 +659,7 @@ int machine_get_uid_shift(Machine *m, uid_t *ret) {
|
||||
uid_t uid_base, uid_shift, uid_range;
|
||||
gid_t gid_base, gid_shift, gid_range;
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
int k, r;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
assert(ret);
|
||||
@@ -718,13 +718,12 @@ int machine_get_uid_shift(Machine *m, uid_t *ret) {
|
||||
|
||||
/* Read the first line. There's at least one. */
|
||||
errno = 0;
|
||||
k = fscanf(f, GID_FMT " " GID_FMT " " GID_FMT "\n", &gid_base, &gid_shift, &gid_range);
|
||||
if (k != 3) {
|
||||
if (ferror(f))
|
||||
return errno_or_else(EIO);
|
||||
|
||||
r = fscanf(f, GID_FMT " " GID_FMT " " GID_FMT "\n", &gid_base, &gid_shift, &gid_range);
|
||||
if (r == EOF)
|
||||
return errno_or_else(ENOMSG);
|
||||
assert(r >= 0);
|
||||
if (r != 3)
|
||||
return -EBADMSG;
|
||||
}
|
||||
|
||||
/* If there's more than one line, then we don't support this file. */
|
||||
r = safe_fgetc(f, NULL);
|
||||
|
||||
Reference in New Issue
Block a user