From: Rafał Miłecki Date: Tue, 23 Dec 2014 20:33:49 +0000 (+0100) Subject: libfstools: ubi: avoid crash in volume finding function X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0bc9aa72941d2e361e77b5ff7c4a742e1de98cc2;p=oweals%2Ffstools.git libfstools: ubi: avoid crash in volume finding function In case /sys/devices/virtual/ubi/ubi?/ubi?_?/name doesn't exist volname will be NULL and calling strlen for NULL isn't a good idea. Signed-off-by: Rafał Miłecki --- diff --git a/libfstools/ubi.c b/libfstools/ubi.c index 866034a..ac9eb1b 100644 --- a/libfstools/ubi.c +++ b/libfstools/ubi.c @@ -143,6 +143,10 @@ static int ubi_volume_match(struct volume *v, char *name, int ubi_num, int volid /* todo: skip existing gluebi device for legacy support */ volname = read_string_from_file(voldir, "name"); + if (!volname) { + fprintf(stderr, "Couldn't read %s/name\n", voldir); + return -1; + } if (strncmp(name, volname, strlen(volname) + 1)) return -1;