[TD-4872]<fix>: fix buffer overflow in -O3 build

This commit is contained in:
Huo Linhe 2021-06-23 14:44:11 +08:00
parent 2e91314d38
commit ebd2fdc156
2 changed files with 4 additions and 2 deletions

View File

@ -480,11 +480,13 @@ static int tfsFormatDir(char *idir, char *odir) {
return -1; return -1;
} }
if (realpath(wep.we_wordv[0], odir) == NULL) { char tmp[PATH_MAX] = {0};
if (realpath(wep.we_wordv[0], tmp) == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
wordfree(&wep); wordfree(&wep);
return -1; return -1;
} }
strcpy(odir, tmp);
wordfree(&wep); wordfree(&wep);
return 0; return 0;

View File

@ -151,7 +151,7 @@ static bool taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) {
wordfree(&full_path); wordfree(&full_path);
char tmp[1025] = {0}; char tmp[PATH_MAX] = {0};
if (realpath(option, tmp) != NULL) { if (realpath(option, tmp) != NULL) {
strcpy(option, tmp); strcpy(option, tmp);
} }