Skip to contentSkip to conversation

memshr: fix off-by-one in filename size check

PATCH In review Matthew Daley 3 participants 4 messages Nov 28, 2013 – Nov 29, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memshr: fix off-by-one in filename size check

---
 tools/memshr/shm.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/memshr/shm.c +2 -2
index c925cf2..30975dc 100644
@@ -217,9 +217,9 @@ uint16_t shm_vbd_image_get(const char* file, vbd_image_info_t *vbd_imgs)
         DPRINTF("No space in vbds table.\n");
         return 0;
     }
-    if(strlen(file) > MAX_NAME_LEN)
+    if(strlen(file) > MAX_NAME_LEN - 1)
     {
-        DPRINTF("Filename: %s too long (>%d).\n", file, MAX_NAME_LEN);
+        DPRINTF("Filename: %s too long (>%d).\n", file, MAX_NAME_LEN - 1);
         return 0; 
     }
     /* Init the entry */
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 1 line · Matthew Daley

Acked + applied, thanks.

Andres -- should you have an entry in MAINTAINERS for this code?

Quoted 20 lines
---
 tools/memshr/shm.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/memshr/shm.c +2 -2
index c925cf2..30975dc 100644
@@ -217,9 +217,9 @@ uint16_t shm_vbd_image_get(const char* file, vbd_image_info_t *vbd_imgs)
         DPRINTF("No space in vbds table.\n");
         return 0;
     }
-    if(strlen(file) > MAX_NAME_LEN)
+    if(strlen(file) > MAX_NAME_LEN - 1)
     {
-        DPRINTF("Filename: %s too long (>%d).\n", file, MAX_NAME_LEN);
+        DPRINTF("Filename: %s too long (>%d).\n", file, MAX_NAME_LEN - 1);
         return 0; 
     }
     /* Init the entry */
#2 lore raw
Quoted 6 lines · Ian Campbell
Quoted 1 line · Matthew Daley

Acked + applied, thanks.

Andres -- should you have an entry in MAINTAINERS for this code?

I manipulated memshr as a side-effect of hypervisor/x86/mem_sharing. It's not my "baby" per se.

I think it'd be more appropriate for me to maintain hypervisor/x86/mem_sharing, and if so, I can take a stab at tools/memshr as well.

Of course, that discussion would involve Tim D (cc) and possibly others.

Thanks
Andres

Quoted 23 lines
Quoted 21 lines

---
tools/memshr/shm.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
tools/memshr/shm.c +2 -2
index c925cf2..30975dc 100644
@@ -217,9 +217,9 @@ uint16_t shm_vbd_image_get(const char* file, vbd_image_info_t *vbd_imgs)
        DPRINTF("No space in vbds table.\n");
        return 0;
    }
-    if(strlen(file) > MAX_NAME_LEN)
+    if(strlen(file) > MAX_NAME_LEN - 1)
    {
-        DPRINTF("Filename: %s too long (>%d).\n", file, MAX_NAME_LEN);
+        DPRINTF("Filename: %s too long (>%d).\n", file, MAX_NAME_LEN - 1);
        return 0; 
    }
    /* Init the entry */
#3 lore raw
Quoted 5 lines · Andres Lagar-Cavilla
Quoted 3 lines · Ian Campbell
Quoted 1 line · Matthew Daley
Quoted 8 lines
Quoted 3 lines

Acked + applied, thanks.

Andres -- should you have an entry in MAINTAINERS for this code?

I manipulated memshr as a side-effect of hypervisor/x86/mem_sharing. It's not my "baby" per se.

I think it'd be more appropriate for me to maintain hypervisor/x86/mem_sharing, and if so, I can take a stab at tools/memshr as well.

Of course, that discussion would involve Tim D (cc) and possibly others.

The best way to kick it off would be with a patch to MAINTAINERS I think.

Ian.