kconfig: Use more collision resistant temporary filenames
kconfig creates reasonably safe filenames for its temporary files except for two of them. Change-Id: I6861f55ae2a5311e3fb7919333ce9af1e39ce78b Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/408 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
3db85f3c1b
commit
f285e04125
|
@ -682,6 +682,7 @@ int conf_write_autoconf(void)
|
||||||
FILE *out, *out_h;
|
FILE *out, *out_h;
|
||||||
time_t now;
|
time_t now;
|
||||||
int i, l;
|
int i, l;
|
||||||
|
char tmpname[128], tmpname_h[128];
|
||||||
|
|
||||||
sym_clear_all_valid();
|
sym_clear_all_valid();
|
||||||
|
|
||||||
|
@ -692,11 +693,13 @@ int conf_write_autoconf(void)
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
out = fopen(".tmpconfig", "w");
|
sprintf(tmpname, ".tmpconfig.%d", (int)getpid());
|
||||||
|
out = fopen(tmpname, "w");
|
||||||
if (!out)
|
if (!out)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
out_h = fopen(".tmpconfig.h", "w");
|
sprintf(tmpname_h, ".tmpconfig.h.%d", (int)getpid());
|
||||||
|
out_h = fopen(tmpname_h, "w");
|
||||||
if (!out_h) {
|
if (!out_h) {
|
||||||
fclose(out);
|
fclose(out);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -791,7 +794,7 @@ int conf_write_autoconf(void)
|
||||||
if (!name)
|
if (!name)
|
||||||
name = "include/linux/autoconf.h";
|
name = "include/linux/autoconf.h";
|
||||||
UNLINK_IF_NECESSARY(name);
|
UNLINK_IF_NECESSARY(name);
|
||||||
if (rename(".tmpconfig.h", name))
|
if (rename(tmpname_h, name))
|
||||||
return 1;
|
return 1;
|
||||||
name = getenv("KCONFIG_AUTOCONFIG");
|
name = getenv("KCONFIG_AUTOCONFIG");
|
||||||
if (!name)
|
if (!name)
|
||||||
|
@ -801,7 +804,7 @@ int conf_write_autoconf(void)
|
||||||
* and this marks the successful completion of the previous steps.
|
* and this marks the successful completion of the previous steps.
|
||||||
*/
|
*/
|
||||||
UNLINK_IF_NECESSARY(name);
|
UNLINK_IF_NECESSARY(name);
|
||||||
if (rename(".tmpconfig", name))
|
if (rename(tmpname, name))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue