[FIX] prevent issue 01/31101/1
authorVitaliy Cherepanov <v.cherepanov@samsung.com>
Mon, 1 Dec 2014 10:50:36 +0000 (13:50 +0300)
committerVitaliy Cherepanov <v.cherepanov@samsung.com>
Mon, 1 Dec 2014 10:50:36 +0000 (13:50 +0300)
+------+-------------------------------+-----------------+-----------+
|ID    | Type                          | file            | function  |
+------+-------------------------------+-----------------+-----------+
|70094 | Dereference before null check | helper/damaps.c | maps_make |
+------+-------------------------------+-----------------+-----------+

Change-Id: Ie772f73313deb8b37698f8d877b265d6a08bb097
Signed-off-by: Vitaliy Cherepanov <v.cherepanov@samsung.com>
helper/damaps.c

index fdfcd0e..4803983 100755 (executable)
@@ -125,14 +125,21 @@ static void print_map(struct map_t *map)
 static int read_mapping_line(FILE *mapfile, struct map_t *m)
 {
        char ch1, ch2;
-       int ret = fscanf(mapfile, "%p-%p %s %llx %s %llx%c%c",
-                        &m->addr,
-                        &m->endaddr,
-                        (char *)m->permissions,
-                        &m->offset,
-                        (char *)m->device,
-                        &m->inode,
-                        &ch1, &ch2);
+       int ret = 0;
+
+       if (m == NULL) {
+               PRINTERR("map_t param is NULL\n");
+               return 0;
+       }
+
+       ret = fscanf(mapfile, "%p-%p %s %llx %s %llx%c%c",
+                    &m->addr,
+                    &m->endaddr,
+                    (char *)m->permissions,
+                    &m->offset,
+                    (char *)m->device,
+                    &m->inode,
+                    &ch1, &ch2);
 
        m->is_instrument = 0;
        if (ret > 0 && ret != EOF) {