[libvirt] [PATCH] Ensure disk names follow the disk name regex

Nitesh Konkar posted 1 patch 7 years, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1486113904-25175-1-git-send-email-niteshkonkar.libvirt@gmail.com
There is a newer version of this series
src/util/virutil.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] Ensure disk names follow the disk name regex
Posted by Nitesh Konkar 7 years, 1 month ago
Currently disk names do not follow the
(regex) /^[fhv]d[a-z]+[0-9]*$/ completely
and hence one can assign disk names like
vd2 etc. This patch ensures that the
disk names follow the regex mentioned.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
---
 src/util/virutil.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virutil.c b/src/util/virutil.c
index 91178d1..2796671 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -563,7 +563,7 @@ int virDiskNameParse(const char *name, int *disk, int *partition)
         }
     }
 
-    if (!ptr)
+    if (!ptr || !c_islower(*ptr))
         return -1;
 
     for (i = 0; *ptr; i++) {
-- 
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Ensure disk names follow the disk name regex
Posted by Nitesh Konkar 7 years, 1 month ago
polite ping.

On Fri, Feb 3, 2017 at 2:55 PM, Nitesh Konkar <
niteshkonkar.libvirt@gmail.com> wrote:

> Currently disk names do not follow the
> (regex) /^[fhv]d[a-z]+[0-9]*$/ completely
> and hence one can assign disk names like
> vd2 etc. This patch ensures that the
> disk names follow the regex mentioned.
>
> Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
> ---
>  src/util/virutil.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/util/virutil.c b/src/util/virutil.c
> index 91178d1..2796671 100644
> --- a/src/util/virutil.c
> +++ b/src/util/virutil.c
> @@ -563,7 +563,7 @@ int virDiskNameParse(const char *name, int *disk, int
> *partition)
>          }
>      }
>
> -    if (!ptr)
> +    if (!ptr || !c_islower(*ptr))
>          return -1;
>
>      for (i = 0; *ptr; i++) {
> --
> 2.1.0
>
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Ensure disk names follow the disk name regex
Posted by Michal Privoznik 7 years, 1 month ago
On 02/03/2017 10:25 AM, Nitesh Konkar wrote:
> Currently disk names do not follow the
> (regex) /^[fhv]d[a-z]+[0-9]*$/ completely
> and hence one can assign disk names like
> vd2 etc. This patch ensures that the
> disk names follow the regex mentioned.
> 
> Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
> ---
>  src/util/virutil.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/util/virutil.c b/src/util/virutil.c
> index 91178d1..2796671 100644
> --- a/src/util/virutil.c
> +++ b/src/util/virutil.c
> @@ -563,7 +563,7 @@ int virDiskNameParse(const char *name, int *disk, int *partition)
>          }
>      }
>  
> -    if (!ptr)
> +    if (!ptr || !c_islower(*ptr))
>          return -1;
>  
>      for (i = 0; *ptr; i++) {
> 

Mind expanding the test suite too? utiltest looks like the best candidate.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Ensure disk names follow the disk name regex
Posted by Nitesh Konkar 7 years, 1 month ago
On Tue, Feb 14, 2017 at 8:47 PM, Michal Privoznik <mprivozn@redhat.com>
wrote:

> On 02/03/2017 10:25 AM, Nitesh Konkar wrote:
> > Currently disk names do not follow the
> > (regex) /^[fhv]d[a-z]+[0-9]*$/ completely
> > and hence one can assign disk names like
> > vd2 etc. This patch ensures that the
> > disk names follow the regex mentioned.
> >
> > Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
> > ---
> >  src/util/virutil.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/util/virutil.c b/src/util/virutil.c
> > index 91178d1..2796671 100644
> > --- a/src/util/virutil.c
> > +++ b/src/util/virutil.c
> > @@ -563,7 +563,7 @@ int virDiskNameParse(const char *name, int *disk,
> int *partition)
> >          }
> >      }
> >
> > -    if (!ptr)
> > +    if (!ptr || !c_islower(*ptr))
> >          return -1;
> >
> >      for (i = 0; *ptr; i++) {
> >
>
> Mind expanding the test suite too? utiltest looks like the best candidate.
>
Sure. Thnx .

>
> Michal
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list