aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorBlue Swirl <blauwirbel@gmail.com>2009-06-09 19:12:21 +0000
committerBlue Swirl <blauwirbel@gmail.com>2009-06-09 19:12:21 +0000
commit3a41759da391b2364589c3542150630402619595 (patch)
tree3e751c1605e53c63fc60afa3f08f640d203ba7e0 /vl.c
parentbab7944cf38dbd5df6bf02b739e9984a4789714b (diff)
Use snprintf to avoid OpenBSD warning
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/vl.c b/vl.c
index c3dc26a1d5..f08f0f3542 100644
--- a/vl.c
+++ b/vl.c
@@ -4834,6 +4834,7 @@ static char *find_datadir(const char *argv0)
#ifdef PATH_MAX
char buf[PATH_MAX];
#endif
+ size_t max_len;
#if defined(__linux__)
{
@@ -4868,11 +4869,12 @@ static char *find_datadir(const char *argv0)
dir = dirname(p);
dir = dirname(dir);
- res = qemu_mallocz(strlen(dir) +
- MAX(strlen(SHARE_SUFFIX), strlen(BUILD_SUFFIX)) + 1);
- sprintf(res, "%s%s", dir, SHARE_SUFFIX);
+ max_len = strlen(dir) +
+ MAX(strlen(SHARE_SUFFIX), strlen(BUILD_SUFFIX)) + 1;
+ res = qemu_mallocz(max_len);
+ snprintf(res, max_len, "%s%s", dir, SHARE_SUFFIX);
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)) {
qemu_free(res);
res = NULL;
@@ -4910,7 +4912,7 @@ char *qemu_find_file(int type, const char *name)
}
len = strlen(data_dir) + strlen(name) + strlen(subdir) + 2;
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)) {
qemu_free(buf);
return NULL;