f = __nscd_query(GETINITGR, user, resp, sizeof resp, &swap);
if (!f) goto cleanup;
- if (f != (FILE*)-1 && resp[INITGRFOUND]) {
+ if (resp[INITGRFOUND]) {
nscdbuf = calloc(resp[INITGRNGRPS], sizeof(uint32_t));
if (!nscdbuf) goto cleanup;
- if (!fread(nscdbuf, sizeof(*nscdbuf)*resp[INITGRNGRPS], 1, f)) {
+ size_t nbytes = sizeof(*nscdbuf)*resp[INITGRNGRPS];
+ if (nbytes && !fread(nscdbuf, nbytes, 1, f)) {
if (!ferror(f)) errno = EIO;
goto cleanup;
}
nscdbuf[i] = bswap_32(nscdbuf[i]);
}
}
- if (f != (FILE*)-1) fclose(f);
+ fclose(f);
f = fopen("/etc/group", "rbe");
if (!f && errno != ENOENT && errno != ENOTDIR)