aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2009-05-08 12:34:17 +0200
committerMark McLoughlin <markmc@redhat.com>2009-06-09 11:38:49 +0100
commit0aa7a205c899c516d906673efbe9457f7af0dd3c (patch)
tree018406ee8a9dda90c0c64161b66eb09d13ca606d /vl.c
parentcda94b27821726df74eead0701d8401c1acda6ec (diff)
downloadqemu-0aa7a205c899c516d906673efbe9457f7af0dd3c.zip
qemu-0aa7a205c899c516d906673efbe9457f7af0dd3c.tar.gz
qemu-0aa7a205c899c516d906673efbe9457f7af0dd3c.tar.bz2
net: Real fix for check_params users
OK, last try: 8e4416af45 broke -net socket, ffad4116b9 tried to fix it but broke error reporting of invalid parameters. So this patch widely reverts ffad4116b9 again and intead fixes those callers of check_params that originally suffered from overwritten buffers by using separate ones. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c39
1 files changed, 14 insertions, 25 deletions
diff --git a/vl.c b/vl.c
index ff438d0..659e9f7 100644
--- a/vl.c
+++ b/vl.c
@@ -1836,45 +1836,34 @@ int get_param_value(char *buf, int buf_size,
return 0;
}
-int check_params(const char * const *params, const char *str)
+int check_params(char *buf, int buf_size,
+ const char * const *params, const char *str)
{
- int name_buf_size = 1;
const char *p;
- char *name_buf;
- int i, len;
- int ret = 0;
-
- for (i = 0; params[i] != NULL; i++) {
- len = strlen(params[i]) + 1;
- if (len > name_buf_size) {
- name_buf_size = len;
- }
- }
- name_buf = qemu_malloc(name_buf_size);
+ int i;
p = str;
while (*p != '\0') {
- p = get_opt_name(name_buf, name_buf_size, p, '=');
+ p = get_opt_name(buf, buf_size, p, '=');
if (*p != '=') {
- ret = -1;
- break;
+ return -1;
}
p++;
- for(i = 0; params[i] != NULL; i++)
- if (!strcmp(params[i], name_buf))
+ for (i = 0; params[i] != NULL; i++) {
+ if (!strcmp(params[i], buf)) {
break;
+ }
+ }
if (params[i] == NULL) {
- ret = -1;
- break;
+ return -1;
}
p = get_opt_value(NULL, 0, p);
- if (*p != ',')
+ if (*p != ',') {
break;
+ }
p++;
}
-
- qemu_free(name_buf);
- return ret;
+ return 0;
}
/***********************************************************/
@@ -2227,7 +2216,7 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque)
"cache", "format", "serial", "werror",
NULL };
- if (check_params(params, str) < 0) {
+ if (check_params(buf, sizeof(buf), params, str) < 0) {
fprintf(stderr, "qemu: unknown parameter '%s' in '%s'\n",
buf, str);
return -1;