commit ecf6e46eb15fefb32da8d87c34db1c6983368cc2 from: Stefan Sperling date: Sun Apr 01 15:21:25 2018 UTC check for fopen() failures in got_diffreg() commit - 16dcbf911ae4975f21c1f64bde440e5ec54fc195 commit + ecf6e46eb15fefb32da8d87c34db1c6983368cc2 blob - c20c1b37c4bb7b60227b956fd033fecaa0c99a90 blob + 813bce5919460541ece9d709acdba5d247b1a361 --- lib/diffreg.c +++ lib/diffreg.c @@ -299,16 +299,21 @@ got_diffreg(int *rval, FILE *f1, FILE *f2, int flags, *rval = (S_ISDIR(ds->stb1.st_mode) ? D_MISMATCH1 : D_MISMATCH2); return NULL; } - if (flags & D_EMPTY1) + if (flags & D_EMPTY1) { f1 = fopen(_PATH_DEVNULL, "r"); + if (f1 == NULL) + return got_error_from_errno(); + } else if (f1 == NULL) { args->status |= 2; goto closem; } - if (flags & D_EMPTY2) + if (flags & D_EMPTY2) { f2 = fopen(_PATH_DEVNULL, "r"); - else if (f2 == NULL) { + if (f2 == NULL) + return got_error_from_errno(); + } else if (f2 == NULL) { args->status |= 2; goto closem; }