mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 00:32:04 +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:
@@ -782,6 +782,7 @@ int conf_write(const char *name)
|
|||||||
const char *str;
|
const char *str;
|
||||||
char dirname[PATH_MAX+1], tmpname[PATH_MAX+22], newname[PATH_MAX+8];
|
char dirname[PATH_MAX+1], tmpname[PATH_MAX+22], newname[PATH_MAX+8];
|
||||||
char *env;
|
char *env;
|
||||||
|
int ret;
|
||||||
|
|
||||||
dirname[0] = 0;
|
dirname[0] = 0;
|
||||||
if (name && name[0]) {
|
if (name && name[0]) {
|
||||||
@@ -804,10 +805,14 @@ int conf_write(const char *name)
|
|||||||
} else
|
} else
|
||||||
basename = conf_get_configname();
|
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");
|
env = getenv("KCONFIG_OVERWRITECONFIG");
|
||||||
if (!env || !*env) {
|
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");
|
out = fopen(tmpname, "w");
|
||||||
} else {
|
} else {
|
||||||
*tmpname = 0;
|
*tmpname = 0;
|
||||||
|
Reference in New Issue
Block a user