diff options
author | Tomas Korbar <tkorbar@redhat.com> | 2020-09-16 14:05:05 +0200 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2020-10-26 16:43:03 -0700 |
commit | 8335dd84ca85651115d518d7e3d963de9d82e22f (patch) | |
tree | 3664bbce88218691322b6e828bbf37a42a8b1eb9 /authfile.c | |
parent | b031143f8ab61296ddbf6c4470c5dcdbf7ae588b (diff) | |
download | memcached-8335dd84ca85651115d518d7e3d963de9d82e22f.tar.gz |
Improve opening of authentication file1.6.8
Diffstat (limited to 'authfile.c')
-rw-r--r-- | authfile.c | 17 |
1 files changed, 5 insertions, 12 deletions
@@ -33,23 +33,16 @@ enum authfile_ret authfile_load(const char *file) { char *auth_data = NULL; auth_t auth_entries[MAX_ENTRIES]; - if (stat(file, &sb) == -1) { - return AUTHFILE_MISSING; - } - - auth_data = calloc(1, sb.st_size); - - if (auth_data == NULL) { - return AUTHFILE_OOM; - } - FILE *pwfile = fopen(file, "r"); if (pwfile == NULL) { - // not strictly necessary but to be safe. - free(auth_data); return AUTHFILE_OPENFAIL; + } else if (fstat(fileno(pwfile), &sb)) { + fclose(pwfile); + return AUTHFILE_STATFAIL; } + auth_data = calloc(1, sb.st_size); + char *auth_cur = auth_data; auth_t *entry_cur = auth_entries; int used = 0; |