summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaliy Cherepanov <v.cherepanov@samsung.com>2014-12-01 13:50:36 +0300
committerVitaliy Cherepanov <v.cherepanov@samsung.com>2014-12-01 13:50:36 +0300
commit425d182c9ede63eb46830ab7d914a44af75b4b2d (patch)
tree73766741d3d82e3f5fa79f60c0ed33421187926d
parent98116c44e77eb309a4ca94520a00e7c885bf2a79 (diff)
downloadswap-probe-425d182c9ede63eb46830ab7d914a44af75b4b2d.tar.gz
swap-probe-425d182c9ede63eb46830ab7d914a44af75b4b2d.tar.bz2
swap-probe-425d182c9ede63eb46830ab7d914a44af75b4b2d.zip
[FIX] prevent issue
+------+-------------------------------+-----------------+-----------+ |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>
-rwxr-xr-xhelper/damaps.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/helper/damaps.c b/helper/damaps.c
index fdfcd0e..4803983 100755
--- a/helper/damaps.c
+++ b/helper/damaps.c
@@ -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) {