diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-09-03 13:40:54 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-09-03 13:40:54 +0000 |
commit | 062994697d10f0fe26525885aa80228b69ef46ff (patch) | |
tree | 2b975f9530008be957c322fa54fed74f82a29716 | |
parent | a1516864b3bb37b610c53516f17a609d64ae4c7e (diff) | |
download | libextractor-062994697d10f0fe26525885aa80228b69ef46ff.tar.gz libextractor-062994697d10f0fe26525885aa80228b69ef46ff.zip |
fix use after free
-rw-r--r-- | src/main/extractor_plugpath.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/main/extractor_plugpath.c b/src/main/extractor_plugpath.c index 450c765..5d6b2ff 100644 --- a/src/main/extractor_plugpath.c +++ b/src/main/extractor_plugpath.c | |||
@@ -305,7 +305,7 @@ get_path_from_PATH() { | |||
305 | LOG_STRERROR ("strdup"); | 305 | LOG_STRERROR ("strdup"); |
306 | return NULL; | 306 | return NULL; |
307 | } | 307 | } |
308 | if (NULL == (buf = malloc (strlen(path) + 20))) | 308 | if (NULL == (buf = malloc (strlen (path) + 20))) |
309 | { | 309 | { |
310 | LOG_STRERROR ("malloc"); | 310 | LOG_STRERROR ("malloc"); |
311 | free (path); | 311 | free (path); |
@@ -315,18 +315,19 @@ get_path_from_PATH() { | |||
315 | while (NULL != (end = strchr(pos, ':'))) | 315 | while (NULL != (end = strchr(pos, ':'))) |
316 | { | 316 | { |
317 | *end = '\0'; | 317 | *end = '\0'; |
318 | sprintf(buf, "%s/%s", pos, "extract"); | 318 | sprintf (buf, "%s/%s", pos, "extract"); |
319 | if (0 == stat(buf, &sbuf)) | 319 | if (0 == stat(buf, &sbuf)) |
320 | { | 320 | { |
321 | free (buf); | 321 | free (buf); |
322 | free (path); | 322 | if (NULL == (pos = strdup (pos))) |
323 | if (NULL == (pos = strdup(pos))) | ||
324 | { | 323 | { |
325 | LOG_STRERROR ("strdup"); | 324 | LOG_STRERROR ("strdup"); |
325 | free (path); | ||
326 | return NULL; | 326 | return NULL; |
327 | } | 327 | } |
328 | free (path); | ||
328 | pos = cut_bin (pos); | 329 | pos = cut_bin (pos); |
329 | if (NULL == (ret = realloc (pos, strlen(pos) + 5))) | 330 | if (NULL == (ret = realloc (pos, strlen (pos) + 5))) |
330 | { | 331 | { |
331 | LOG_STRERROR ("realloc"); | 332 | LOG_STRERROR ("realloc"); |
332 | free (pos); | 333 | free (pos); |
@@ -337,7 +338,7 @@ get_path_from_PATH() { | |||
337 | } | 338 | } |
338 | pos = end + 1; | 339 | pos = end + 1; |
339 | } | 340 | } |
340 | sprintf(buf, "%s/%s", pos, "extract"); | 341 | sprintf (buf, "%s/%s", pos, "extract"); |
341 | if (0 == stat (buf, &sbuf)) | 342 | if (0 == stat (buf, &sbuf)) |
342 | { | 343 | { |
343 | pos = strdup (pos); | 344 | pos = strdup (pos); |
@@ -346,7 +347,7 @@ get_path_from_PATH() { | |||
346 | if (NULL == pos) | 347 | if (NULL == pos) |
347 | return NULL; | 348 | return NULL; |
348 | pos = cut_bin (pos); | 349 | pos = cut_bin (pos); |
349 | if (NULL == (ret = realloc (pos, strlen(pos) + 5))) | 350 | if (NULL == (ret = realloc (pos, strlen (pos) + 5))) |
350 | { | 351 | { |
351 | LOG_STRERROR ("realloc"); | 352 | LOG_STRERROR ("realloc"); |
352 | free (pos); | 353 | free (pos); |
@@ -355,8 +356,8 @@ get_path_from_PATH() { | |||
355 | strcat (ret, "lib/"); | 356 | strcat (ret, "lib/"); |
356 | return ret; | 357 | return ret; |
357 | } | 358 | } |
358 | free(buf); | 359 | free (buf); |
359 | free(path); | 360 | free (path); |
360 | return NULL; | 361 | return NULL; |
361 | } | 362 | } |
362 | 363 | ||