libxenlight: fix segfault when reading blktap2 devs
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 1 Dec 2009 13:34:38 +0000 (13:34 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 1 Dec 2009 13:34:38 +0000 (13:34 +0000)
This patch fixes a possible segfault when reading from
/sys/class/blktap2/devices, if the line read is empty.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
tools/libxl/libxl.c

index abab8379529b4360bc6ca68c321210b8d2a0c69d..eaa22253e6d422b033d255f3015adb44a93d5344 100644 (file)
@@ -937,6 +937,8 @@ static char *get_blktap2_device(struct libxl_ctx *ctx, char *name, char *type)
     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);