Skip to contentSkip to conversation

libxenlight: fix segfault when reading blktap2 devs

PATCH New Stefano Stabellini 1 participant 1 message Nov 30, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxenlight: fix segfault when reading blktap2 devs

Hi all,
this patch fixes a possible segfault when reading from /sys/class/blktap2/devices, if the line read is empty.

---

tools/libxl/libxl.c +2 -0
diff -r 1b0554b495f8 tools/libxl/libxl.c
@@ -940,6 +940,8 @@
     while (!feof(f)) {
         fscanf(f, "%d %s", &devnum, buf);
         p = strchr(buf, ':');
+        if (p == NULL)
+            continue;
         p++;
         if (!strcmp(p, name) && !strncmp(buf, type, 3)) {
             fclose(f);