diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-12-17 11:22:38 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-12-18 15:03:00 +0100 |
commit | 03a7dbeae051a5b655eb956f335024bfba8599d1 (patch) | |
tree | ee4f52fe162cd625e7aa71907548c21d5721206e /src/machine | |
parent | 285a9b274978349cfd762a6cd6e6aa666909ec5e (diff) | |
download | systemd-03a7dbeae051a5b655eb956f335024bfba8599d1.tar.gz systemd-03a7dbeae051a5b655eb956f335024bfba8599d1.tar.bz2 systemd-03a7dbeae051a5b655eb956f335024bfba8599d1.zip |
tree-wide: port some code over to safe_fgetc()
Diffstat (limited to 'src/machine')
-rw-r--r-- | src/machine/machine.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/machine/machine.c b/src/machine/machine.c index beb5b3566a..4f89ac026d 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -594,7 +594,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; + int k, r; assert(m); assert(ret); @@ -643,7 +643,10 @@ int machine_get_uid_shift(Machine *m, uid_t *ret) { return -ENXIO; /* If there's more than one line, then we don't support this mapping. */ - if (fgetc(f) != EOF) + r = safe_fgetc(f, NULL); + if (r < 0) + return r; + if (r != 0) /* Insist on EOF */ return -ENXIO; fclose(f); @@ -664,7 +667,10 @@ int machine_get_uid_shift(Machine *m, uid_t *ret) { } /* If there's more than one line, then we don't support this file. */ - if (fgetc(f) != EOF) + r = safe_fgetc(f, NULL); + if (r < 0) + return r; + if (r != 0) /* Insist on EOF */ return -ENXIO; /* If the UID and GID mapping doesn't match, we don't support this mapping. */ |