Backport -net socket fixes
cover Backport -net socket fixes
Backport fixes for -net socket option. It fixes a segfault described at https://bugzilla.redhat.com/show_bug.cgi?id=501264
PATCH 1/2 net: Fix -net socket, listen (Jan Kiszka)
From: aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
In case no symbolic name is provided when requesting VLAN connection via listening TCP socket ('-net socket,listen=...'), qemu crashes. This fixes the cause.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7196 c046a42c-6fe2-441c-8c8c-71466251a162
--- net.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net.c +1 -1
@@ -1468,7 +1468,7 @@ static int net_socket_listen_init(VLANState *vlan, } s->vlan = vlan; s->model =strdup (model); - s->name =strdup (name); + s->name = name ?strdup (name) :NULL ; s->fd = fd;qemu_set_fd_handler (fd, net_socket_accept,NULL , s);return 0 ;
Signature · 1 line
1.5.6.6
PATCH 2/2 net: Fix -net socket parameter checks
My commit ea053add700d8abe203cd79a9ffb082aee4eabc0 broke -net socket by overwriting an intermediate buffer in the added check_param. Fix this by switching check_param to automatic buffer allocation and release, ie. callers no longer have to worry about providing a scratch buffer.
--- sysemu.h | 3 +-- vl.c | 32 +++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-)
sysemu.h +1 -2
@@ -245,7 +245,6 @@ const char *get_opt_name(char *buf, int buf_size, const char *p);const char *get_opt_value (char *buf,int buf_size,const char *p);int get_param_value (char *buf,int buf_size,const char *tag,const char *str); -int check_params (char *buf,int buf_size, -const char *const *params,const char *str); +int check_params (const char *const *params,const char *str);#endif
vl.c +23 -9
@@ -1918,29 +1918,43 @@ int get_param_value(char *buf, int buf_size,return 0 ; } -int check_params (char *buf,int buf_size, -const char *const *params,const char *str) +int check_params (const char *const *params,const char *str) { +int name_buf_size =1 ;const char *p; -int i; +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); p = str;for (;;) { - p =get_opt_name (buf, buf_size, p); + p =get_opt_name (name_buf, name_buf_size, p);if (*p !='=' )return -1 ; p++;for (i =0 ; params[i] !=NULL ; i++) -if (!strcmp (params[i], buf)) +if (!strcmp (params[i], name_buf))break ; -if (params[i] ==NULL ) -return -1 ; +if (params[i] ==NULL ) { + ret =-1 ; +break ; + } p =get_opt_value (NULL ,0 , p);if (*p !=',' )break ; p++; } -return 0 ; + +qemu_free (name_buf); +return ret; }/***********************************************************/
@@ -2297,7 +2311,7 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque)"cache" ,"format" ,"serial" ,"werror" , NULL }; -if (check_params (buf,sizeof (buf), params, str) <0 ) { +if (check_params (params, str) <0 ) {fprintf (stderr,"qemu: unknown parameter '%s' in '%s'\n" , buf, str);return -1 ;
Signature · 1 line
1.5.6.6
[Qemu-devel] Re: [PATCH STABLE 2/2] net: Fix -net socket parameter checks
Quoted 4 lines · Glauber Costa
My commit
ea053add700d8abe203cd79a9ffb082aee4eabc0broke -net socket by overwriting an intermediate buffer in the addedcheck_param. Fix this by switchingcheck_paramto automatic buffer allocation and release, ie. callers no longer have to worry about providing a scratch buffer.
That commit was buggy, too, and is awaiting to be fixed in unstable by
http://permalink.gmane.org/gmane.comp.emulators.qemu/43041.
But more importantly, it makes no sense in stable because its "heart", param checking for -net is only in unstable (and that's perfectly fine).
Jan
[Qemu-devel] Re: [PATCH STABLE 2/2] net: Fix -net socket parameter checks
Quoted 11 lines · Jan Kiszka
Quoted 4 lines · Glauber Costa
My commit
ea053add700d8abe203cd79a9ffb082aee4eabc0broke -net socket by overwriting an intermediate buffer in the addedcheck_param. Fix this by switchingcheck_paramto automatic buffer allocation and release, ie. callers no longer have to worry about providing a scratch buffer.That commit was buggy, too, and is awaiting to be fixed in unstable by
http://permalink.gmane.org/gmane.comp.emulators.qemu/43041.But more importantly, it makes no sense in stable because its "heart", param checking for -net is only in unstable (and that's perfectly fine).
My interest was in the previous one, since it fixes a bug reported by a Fedora user. I picked this one, only because it fixes the fix ;-)
But I can happily leave it out, if you think it is better.
[Qemu-devel] Re: [PATCH STABLE 2/2] net: Fix -net socket parameter checks
Quoted 6 lines · Glauber Costa
Quoted 5 lines · Jan Kiszka
Quoted 4 lines · Glauber Costa
My commit
ea053add700d8abe203cd79a9ffb082aee4eabc0broke -net socket by overwriting an intermediate buffer in the addedcheck_param. Fix this by switchingcheck_paramto automatic buffer allocation and release, ie. callers no longer have to worry about providing a scratch buffer.
Quoted 8 lines
Quoted 5 lines
That commit was buggy, too, and is awaiting to be fixed in unstable by
http://permalink.gmane.org/gmane.comp.emulators.qemu/43041.But more importantly, it makes no sense in stable because its "heart", param checking for -net is only in unstable (and that's perfectly fine).
My interest was in the previous one, since it fixes a bug reported by a Fedora user. I picked this one, only because it fixes the fix ;-)
But I can happily leave it out, if you think it is better.
This patch 2 has never been a fix of patch 1 in your series. I agree that 1/2 is worth considering for stable, but that one never required any addon fix.
Jan
[Qemu-devel] Re: [PATCH STABLE 2/2] net: Fix -net socket parameter checks
Quoted 12 lines · Jan Kiszka
Quoted 11 lines · Glauber Costa
Quoted 10 lines · Jan Kiszka
Quoted 4 lines · Glauber Costa
My commit
ea053add700d8abe203cd79a9ffb082aee4eabc0broke -net socket by overwriting an intermediate buffer in the addedcheck_param. Fix this by switchingcheck_paramto automatic buffer allocation and release, ie. callers no longer have to worry about providing a scratch buffer.That commit was buggy, too, and is awaiting to be fixed in unstable by
http://permalink.gmane.org/gmane.comp.emulators.qemu/43041.But more importantly, it makes no sense in stable because its "heart", param checking for -net is only in unstable (and that's perfectly fine).
Quoted 7 lines
Quoted 3 lines
My interest was in the previous one, since it fixes a bug reported by a Fedora user. I picked this one, only because it fixes the fix ;-)
But I can happily leave it out, if you think it is better.This patch 2 has never been a fix of patch 1 in your series. I agree that 1/2 is worth considering for stable, but that one never required any addon fix.
I got the wrong impression from your changelog then.
Thanks for taking a look
[Qemu-devel] Re: [PATCH STABLE 2/2] net: Fix -net socket parameter checks
Quoted 16 lines · Glauber Costa
Quoted 15 lines · Jan Kiszka
Quoted 14 lines · Glauber Costa
Quoted 10 lines · Jan Kiszka
Quoted 4 lines · Glauber Costa
My commit
ea053add700d8abe203cd79a9ffb082aee4eabc0broke -net socket by overwriting an intermediate buffer in the addedcheck_param. Fix this by switchingcheck_paramto automatic buffer allocation and release, ie. callers no longer have to worry about providing a scratch buffer.That commit was buggy, too, and is awaiting to be fixed in unstable by
http://permalink.gmane.org/gmane.comp.emulators.qemu/43041.But more importantly, it makes no sense in stable because its "heart", param checking for -net is only in unstable (and that's perfectly fine).
My interest was in the previous one, since it fixes a bug reported by a Fedora user. I picked this one, only because it fixes the fix ;-)
But I can happily leave it out, if you think it is better.
Quoted 6 lines
Quoted 3 lines
This patch 2 has never been a fix of patch 1 in your series. I agree that 1/2 is worth considering for stable, but that one never required any addon fix.
I got the wrong impression from your changelog then.
Thanks for taking a look
Oh, off-by-one while picking up the hash for this changelog. Should have been 8e4416af458b5fdfc81950005e358de02511eb9f. My bad.
Jan