提交 80fb564b 编写于 作者: D Daniel Veillard

* TODO qemud/conf.c src/virsh.c src/xend_internal.c src/xs_internal.c:

  replaced all sprintf instances by snprintf ones
Daniel
上级 ba83eae4
Fri Mar 23 17:14:10 CET 2007 Daniel Veillard <veillard@redhat.com>
* TODO qemud/conf.c src/virsh.c src/xend_internal.c src/xs_internal.c:
replaced all sprintf instances by snprintf ones
Fri Mar 23 09:12:00 UTC 2007 Richard W.M. Jones <rjones@redhat.com>
* src/xen_internal.c: Fix detection of host PAE capabilities,
......
TODO:
- libvirt_virDomainSetMemory should check memory is > 0
- remove calls from sprintf and use snprintf
- check how to better handle renaming of domains (xm rename and cache)
- UUID lookup in hash.c
......
......@@ -1196,8 +1196,8 @@ int qemudBuildCommandLine(struct qemud_server *server,
(vm->def->graphicsType == QEMUD_GRAPHICS_VNC ? 2 :
(vm->def->graphicsType == QEMUD_GRAPHICS_SDL ? 0 : 1)); /* graphics */
sprintf(memory, "%d", vm->def->memory/1024);
sprintf(vcpus, "%d", vm->def->vcpus);
snprintf(memory, sizeof(memory), "%d", vm->def->memory/1024);
snprintf(vcpus, sizeof(vcpus), "%d", vm->def->vcpus);
if (!(*argv = malloc(sizeof(char *) * (len+1))))
goto no_memory;
......
......@@ -3282,7 +3282,7 @@ vshReadlineOptionsGenerator(const char *text, int state)
continue;
}
res = vshMalloc(NULL, strlen(name) + 3);
sprintf(res, "--%s", name);
snprintf(res, strlen(name) + 3, "--%s", name);
return res;
}
......
......@@ -799,7 +799,7 @@ urlencode(const char *string)
switch (string[i]) {
case ' ':
case '\n':
sprintf(ptr, "%%%02x", string[i]);
snprintf(ptr, 4, "%%%02x", string[i]);
ptr += 3;
break;
default:
......@@ -2670,7 +2670,7 @@ xenDaemonDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
/* from bit map, build character string of mapped CPU numbers */
for (i = 0; i < maplen; i++) for (j = 0; j < 8; j++)
if (cpumap[i] & (1 << j)) {
sprintf(buf, "%d,", (8 * i) + j);
snprintf(buf, sizeof(buf), "%d,", (8 * i) + j);
strcat(mapstr, buf);
}
mapstr[strlen(mapstr) - 1] = ']';
......
......@@ -818,12 +818,12 @@ xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac) {
if (maclen <= 0)
return (NULL);
sprintf(dir, "/local/domain/0/backend/vif/%d", id);
snprintf(dir, sizeof(dir), "/local/domain/0/backend/vif/%d", id);
list = xs_directory(conn->xshandle, 0, dir, &num);
if (list == NULL)
return(NULL);
for (i = 0; i < num; i++) {
sprintf(path, "%s/%s/%s", dir, list[i], "mac");
snprintf(path, sizeof(path), "%s/%s/%s", dir, list[i], "mac");
val = xs_read(conn->xshandle, 0, path, &len);
if (val == NULL)
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册