Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85691421 authored by Johan Harvyl's avatar Johan Harvyl Committed by Johan Redestig
Browse files

Handle error from fopen_path in finish_recovery

The fopen_path will fail here e.g. if /cache is corrupt and could
not be mounted. Not properly handling an error code from
fopen_path() results in a boot loop into recovery as fwrite() on
a NULL FILE object will crash the recovery app.

Change-Id: I1ccff5a8cb620a32f32adfe97a3fae8e5e908f39
parent 61240f88
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -504,12 +504,14 @@ finish_recovery() {
        if (has_cache) {
            LOGI("Saving locale \"%s\"\n", locale);
            FILE* fp = fopen_path(LOCALE_FILE, "w");
            if (fp != NULL) {
                fwrite(locale, 1, len, fp);
                fflush(fp);
                fsync(fileno(fp));
                check_and_fclose(fp, LOCALE_FILE);
            }
        }
    }

    copy_logs();