Patchwork [STABLE] Fix corner case in chardev udp: parameter

login
register
mail settings
Submitter Jan Kiszka
Date Jan. 15, 2010, 8:07 p.m.
Message ID <4B50CAEA.6070900@web.de>
Download mbox | patch
Permalink /patch/42994/
State New
Headers show

Comments

Jan Kiszka - Jan. 15, 2010, 8:07 p.m.
The missing '@' broke 'udp::<port>@:<port>' parsing.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

 qemu-char.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Gerd Hoffmann - Jan. 18, 2010, 9:24 a.m.
On 01/15/10 21:07, Jan Kiszka wrote:
> The missing '@' broke 'udp::<port>@:<port>' parsing.

>           if (sscanf(p, "%64[^:]:%32[^@,]%n", host, port,&pos)<  2) {
>               host[0] = 0;
> -            if (sscanf(p, ":%32[^,]%n", port,&pos)<  1) {
> +            if (sscanf(p, ":%32[^@,]%n", port,&pos)<  1) {

Indeed.

>                   fprintf(stderr, "udp #1\n");

While you are at it, can you also zap this debug leftover?

thanks,
   Gerd
Jan Kiszka - Jan. 18, 2010, 10:21 a.m.
Gerd Hoffmann wrote:
> On 01/15/10 21:07, Jan Kiszka wrote:
>> The missing '@' broke 'udp::<port>@:<port>' parsing.
> 
>>           if (sscanf(p, "%64[^:]:%32[^@,]%n", host, port,&pos)<  2) {
>>               host[0] = 0;
>> -            if (sscanf(p, ":%32[^,]%n", port,&pos)<  1) {
>> +            if (sscanf(p, ":%32[^@,]%n", port,&pos)<  1) {
> 
> Indeed.
> 
>>                   fprintf(stderr, "udp #1\n");
> 
> While you are at it, can you also zap this debug leftover?

Looks like there are three of them in qemu_chr_parse_compat - kill them all?

Jan
Gerd Hoffmann - Jan. 18, 2010, 10:47 a.m.
On 01/18/10 11:21, Jan Kiszka wrote:
> Gerd Hoffmann wrote:
>> On 01/15/10 21:07, Jan Kiszka wrote:
>>> The missing '@' broke 'udp::<port>@:<port>' parsing.
>>
>>>            if (sscanf(p, "%64[^:]:%32[^@,]%n", host, port,&pos)<   2) {
>>>                host[0] = 0;
>>> -            if (sscanf(p, ":%32[^,]%n", port,&pos)<   1) {
>>> +            if (sscanf(p, ":%32[^@,]%n", port,&pos)<   1) {
>>
>> Indeed.
>>
>>>                    fprintf(stderr, "udp #1\n");
>>
>> While you are at it, can you also zap this debug leftover?
>
> Looks like there are three of them in qemu_chr_parse_compat - kill them all?

Yes.

thanks,
   Gerd

Patch

diff --git a/qemu-char.c b/qemu-char.c
index b13f8d4..a8a92f5 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2314,7 +2314,7 @@  QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename)
         qemu_opt_set(opts, "backend", "udp");
         if (sscanf(p, "%64[^:]:%32[^@,]%n", host, port, &pos) < 2) {
             host[0] = 0;
-            if (sscanf(p, ":%32[^,]%n", port, &pos) < 1) {
+            if (sscanf(p, ":%32[^@,]%n", port, &pos) < 1) {
                 fprintf(stderr, "udp #1\n");
                 goto fail;
             }