Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/em100/+/37072 )
Change subject: Add network update functionality ......................................................................
Patch Set 15: Code-Review+1
(1 comment)
https://review.coreboot.org/c/em100/+/37072/15/curl.c File curl.c:
https://review.coreboot.org/c/em100/+/37072/15/curl.c@145 PS15, Line 145: fclose(old); Will result in UB if `old` is NULL. Here is my suggestion.
In any case, looks like `unlink()` is not needed. However, the function `get_em100_file()` returns the return of `strdup()`, which must be freed to avoid a memory leak.
int update_all_files(void) { FILE *old = fopen(get_em100_file(version_name), "r"); if (!old) return 1;
char *tmp_version = get_em100_file(".VERSION.new"); curl_get(version_id, tmp_version, 0);
FILE *new = fopen(tmp_version, "r"); if (!new) fclose(old); return 1; }
/* Time: 1574638611 * Version: 4.3.03 */