From 0bc9aa72941d2e361e77b5ff7c4a742e1de98cc2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Tue, 23 Dec 2014 21:33:49 +0100 Subject: [PATCH] libfstools: ubi: avoid crash in volume finding function MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- libfstools/ubi.c | 4 ++++ 1 file changed, 4 insertions(+) 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; -- 2.25.1