forked from github/server
CID 22557: Copy into fixed size buffer (STRING_OVERFLOW)
eliminate code duplication. bsdstring is better than libc strings.
This commit is contained in:
parent
ca7d25858e
commit
1fb04179dc
|
@ -1082,13 +1082,19 @@ int check_param(const struct param *p, const char *key, const char *searchvalue)
|
|||
return result;
|
||||
}
|
||||
|
||||
const char * relpath(char *buf, size_t sz, const char *path) {
|
||||
strlcpy(buf, basepath(), sz);
|
||||
strlcat(buf, path, sz);
|
||||
return buf;
|
||||
}
|
||||
|
||||
static const char *g_datadir;
|
||||
const char *datapath(void)
|
||||
{
|
||||
static char zText[MAX_PATH]; // FIXME: static return value
|
||||
if (g_datadir)
|
||||
return g_datadir;
|
||||
return strcat(strcpy(zText, basepath()), "/data");
|
||||
return relpath(zText, sizeof(zText), "/data");
|
||||
}
|
||||
|
||||
void set_datapath(const char *path)
|
||||
|
@ -1102,7 +1108,7 @@ const char *reportpath(void)
|
|||
static char zText[MAX_PATH]; // FIXME: static return value
|
||||
if (g_reportdir)
|
||||
return g_reportdir;
|
||||
return strcat(strcpy(zText, basepath()), "/reports");
|
||||
return relpath(zText, sizeof(zText), "/reports");
|
||||
}
|
||||
|
||||
void set_reportpath(const char *path)
|
||||
|
|
Loading…
Reference in New Issue