mirror of https://github.com/xemu-project/xemu.git
Use snprintf to avoid OpenBSD warning
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
bab7944cf3
commit
3a41759da3
12
vl.c
12
vl.c
|
@ -4834,6 +4834,7 @@ static char *find_datadir(const char *argv0)
|
||||||
#ifdef PATH_MAX
|
#ifdef PATH_MAX
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
#endif
|
#endif
|
||||||
|
size_t max_len;
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
{
|
{
|
||||||
|
@ -4868,11 +4869,12 @@ static char *find_datadir(const char *argv0)
|
||||||
dir = dirname(p);
|
dir = dirname(p);
|
||||||
dir = dirname(dir);
|
dir = dirname(dir);
|
||||||
|
|
||||||
res = qemu_mallocz(strlen(dir) +
|
max_len = strlen(dir) +
|
||||||
MAX(strlen(SHARE_SUFFIX), strlen(BUILD_SUFFIX)) + 1);
|
MAX(strlen(SHARE_SUFFIX), strlen(BUILD_SUFFIX)) + 1;
|
||||||
sprintf(res, "%s%s", dir, SHARE_SUFFIX);
|
res = qemu_mallocz(max_len);
|
||||||
|
snprintf(res, max_len, "%s%s", dir, SHARE_SUFFIX);
|
||||||
if (access(res, R_OK)) {
|
if (access(res, R_OK)) {
|
||||||
sprintf(res, "%s%s", dir, BUILD_SUFFIX);
|
snprintf(res, max_len, "%s%s", dir, BUILD_SUFFIX);
|
||||||
if (access(res, R_OK)) {
|
if (access(res, R_OK)) {
|
||||||
qemu_free(res);
|
qemu_free(res);
|
||||||
res = NULL;
|
res = NULL;
|
||||||
|
@ -4910,7 +4912,7 @@ char *qemu_find_file(int type, const char *name)
|
||||||
}
|
}
|
||||||
len = strlen(data_dir) + strlen(name) + strlen(subdir) + 2;
|
len = strlen(data_dir) + strlen(name) + strlen(subdir) + 2;
|
||||||
buf = qemu_mallocz(len);
|
buf = qemu_mallocz(len);
|
||||||
sprintf(buf, "%s/%s%s", data_dir, subdir, name);
|
snprintf(buf, len, "%s/%s%s", data_dir, subdir, name);
|
||||||
if (access(buf, R_OK)) {
|
if (access(buf, R_OK)) {
|
||||||
qemu_free(buf);
|
qemu_free(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue