Patchwork [v3,5/5] block: Prevent /dev/fd/X filename from being detected as floppy

login
register
mail settings
Submitter Corey Bryant
Date June 14, 2012, 3:55 p.m.
Message ID <1339689305-27031-6-git-send-email-coreyb@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/164958/
State New
Headers show

Comments

Corey Bryant - June 14, 2012, 3:55 p.m.
Reported-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
---
v3:
 -This patch is new in v3.  It was previously submitted on its
  own, and is now being included in this series.

 block/raw-posix.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Luiz Capitulino - June 15, 2012, 2:38 p.m.
On Thu, 14 Jun 2012 11:55:05 -0400
Corey Bryant <coreyb@linux.vnet.ibm.com> wrote:

> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>

This too, would be better to move before the /dev/fd/X feature so that we
avoid having introducing a bug and fixing it in a later commit. But again,
it's not a huge issue.

> ---
> v3:
>  -This patch is new in v3.  It was previously submitted on its
>   own, and is now being included in this series.
> 
>  block/raw-posix.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/block/raw-posix.c b/block/raw-posix.c
> index d8eff2f..68886cd 100644
> --- a/block/raw-posix.c
> +++ b/block/raw-posix.c
> @@ -946,9 +946,11 @@ static int floppy_probe_device(const char *filename)
>      int prio = 0;
>      struct floppy_struct fdparam;
>      struct stat st;
> +    const char *p;
>  
> -    if (strstart(filename, "/dev/fd", NULL))
> +    if (strstart(filename, "/dev/fd", &p) && p[0] != '/') {
>          prio = 50;
> +    }
>  
>      fd = qemu_open(filename, O_RDONLY | O_NONBLOCK);
>      if (fd < 0) {
Corey Bryant - June 15, 2012, 3:12 p.m.
On 06/15/2012 10:38 AM, Luiz Capitulino wrote:
> On Thu, 14 Jun 2012 11:55:05 -0400
> Corey Bryant <coreyb@linux.vnet.ibm.com> wrote:
>
>> Reported-by: Kevin Wolf <kwolf@redhat.com>
>> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
>> Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
>
> This too, would be better to move before the /dev/fd/X feature so that we
> avoid having introducing a bug and fixing it in a later commit. But again,
> it's not a huge issue.
>

Yes, this one makes even more sense to move earlier in the series.  Thanks.

>> ---
>> v3:
>>   -This patch is new in v3.  It was previously submitted on its
>>    own, and is now being included in this series.
>>
>>   block/raw-posix.c |    4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/block/raw-posix.c b/block/raw-posix.c
>> index d8eff2f..68886cd 100644
>> --- a/block/raw-posix.c
>> +++ b/block/raw-posix.c
>> @@ -946,9 +946,11 @@ static int floppy_probe_device(const char *filename)
>>       int prio = 0;
>>       struct floppy_struct fdparam;
>>       struct stat st;
>> +    const char *p;
>>
>> -    if (strstart(filename, "/dev/fd", NULL))
>> +    if (strstart(filename, "/dev/fd", &p) && p[0] != '/') {
>>           prio = 50;
>> +    }
>>
>>       fd = qemu_open(filename, O_RDONLY | O_NONBLOCK);
>>       if (fd < 0) {
>

Patch

diff --git a/block/raw-posix.c b/block/raw-posix.c
index d8eff2f..68886cd 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -946,9 +946,11 @@  static int floppy_probe_device(const char *filename)
     int prio = 0;
     struct floppy_struct fdparam;
     struct stat st;
+    const char *p;
 
-    if (strstart(filename, "/dev/fd", NULL))
+    if (strstart(filename, "/dev/fd", &p) && p[0] != '/') {
         prio = 50;
+    }
 
     fd = qemu_open(filename, O_RDONLY | O_NONBLOCK);
     if (fd < 0) {