mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-10-23 08:12:01 +00:00
gtphub: Fix use after free on failure
Even if fclose fails the stream is inaccessible and the second fclose might cause memory violation. Linux manpage says: Upon successful completion 0 is returned. Otherwise, EOF is returned and errno is set to indicate the error. In either case any further access (including another call to fclose()) to the stream results in undefined behavior. Fixes: CID#57958
This commit is contained in:
@@ -166,8 +166,10 @@ static uint8_t next_restart_count(const char *path)
|
|||||||
goto failed_to_write;
|
goto failed_to_write;
|
||||||
if (fprintf(f, "%" PRIu8 "\n", counter) < 2)
|
if (fprintf(f, "%" PRIu8 "\n", counter) < 2)
|
||||||
goto failed_to_write;
|
goto failed_to_write;
|
||||||
if (fclose(f))
|
if (fclose(f)) {
|
||||||
|
f = NULL;
|
||||||
goto failed_to_write;
|
goto failed_to_write;
|
||||||
|
}
|
||||||
|
|
||||||
umask(umask_was);
|
umask(umask_was);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user