1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-08-31 16:22:36 +02:00

Use snprintf in confdata.c to avoid possible buffer overflow

And gcc8 warnings.

Signed-off-by: Ondrej Jirman <megous@megous.com>
This commit is contained in:
Ondrej Jirman
2018-07-09 07:16:20 +02:00
parent 050acee119
commit e8cf7d2736

View File

@@ -782,6 +782,7 @@ int conf_write(const char *name)
const char *str;
char dirname[PATH_MAX+1], tmpname[PATH_MAX+22], newname[PATH_MAX+8];
char *env;
int ret;
dirname[0] = 0;
if (name && name[0]) {
@@ -804,10 +805,14 @@ int conf_write(const char *name)
} else
basename = conf_get_configname();
sprintf(newname, "%s%s", dirname, basename);
ret = snprintf(newname, sizeof newname, "%s%s", dirname, basename);
if (ret == sizeof newname)
return 1;
env = getenv("KCONFIG_OVERWRITECONFIG");
if (!env || !*env) {
sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
ret = snprintf(tmpname, sizeof tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
if (ret == sizeof tmpname)
return 1;
out = fopen(tmpname, "w");
} else {
*tmpname = 0;