+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
(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;
continue;
}
res = vshMalloc(NULL, strlen(name) + 3);
- sprintf(res, "--%s", name);
+ snprintf(res, strlen(name) + 3, "--%s", name);
return res;
}
switch (string[i]) {
case ' ':
case '\n':
- sprintf(ptr, "%%%02x", string[i]);
+ snprintf(ptr, 4, "%%%02x", string[i]);
ptr += 3;
break;
default:
/* 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] = ']';
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;