diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-06-12 15:09:44 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-06-12 15:09:44 +0000 |
commit | 91fb214deea3390b64b304b6b08e533327881fbe (patch) | |
tree | 63982445c1b1e90bc75bac5cfa4874297dd98d5f | |
parent | fa109a96494188832f68bf31b7bbb465b624f006 (diff) | |
download | libextractor-91fb214deea3390b64b304b6b08e533327881fbe.tar.gz libextractor-91fb214deea3390b64b304b6b08e533327881fbe.zip |
fixes
-rw-r--r-- | src/main/extractor.c | 40 | ||||
-rw-r--r-- | src/plugins/flv_extractor.c | 2 |
2 files changed, 32 insertions, 10 deletions
diff --git a/src/main/extractor.c b/src/main/extractor.c index 36ed638..7c2981c 100644 --- a/src/main/extractor.c +++ b/src/main/extractor.c | |||
@@ -175,6 +175,7 @@ get_path_from_proc_exe() { | |||
175 | char line[1024]; | 175 | char line[1024]; |
176 | char dir[1024]; | 176 | char dir[1024]; |
177 | char * lnk; | 177 | char * lnk; |
178 | char * lestr; | ||
178 | size_t size; | 179 | size_t size; |
179 | FILE * f; | 180 | FILE * f; |
180 | 181 | ||
@@ -188,9 +189,9 @@ get_path_from_proc_exe() { | |||
188 | if ( (1 == sscanf(line, | 189 | if ( (1 == sscanf(line, |
189 | "%*x-%*x %*c%*c%*c%*c %*x %*2x:%*2x %*u%*[ ]%s", | 190 | "%*x-%*x %*c%*c%*c%*c %*x %*2x:%*2x %*u%*[ ]%s", |
190 | dir)) && | 191 | dir)) && |
191 | (NULL != strstr(dir, | 192 | (NULL != (lestr = strstr(dir, |
192 | "libextractor")) ) { | 193 | "libextractor")) ) ) { |
193 | strstr(dir, "libextractor")[0] = '\0'; | 194 | lestr[0] = '\0'; |
194 | fclose(f); | 195 | fclose(f); |
195 | return strdup(dir); | 196 | return strdup(dir); |
196 | } | 197 | } |
@@ -202,6 +203,8 @@ get_path_from_proc_exe() { | |||
202 | "/proc/%u/exe", | 203 | "/proc/%u/exe", |
203 | getpid()); | 204 | getpid()); |
204 | lnk = malloc(1029); /* 1024 + 5 for "lib/" catenation */ | 205 | lnk = malloc(1029); /* 1024 + 5 for "lib/" catenation */ |
206 | if (lnk == NULL) | ||
207 | return NULL; | ||
205 | size = readlink(fn, lnk, 1023); | 208 | size = readlink(fn, lnk, 1023); |
206 | if ( (size == 0) || (size >= 1024) ) { | 209 | if ( (size == 0) || (size >= 1024) ) { |
207 | free(lnk); | 210 | free(lnk); |
@@ -220,6 +223,8 @@ get_path_from_proc_exe() { | |||
220 | lnk[size] = '\0'; | 223 | lnk[size] = '\0'; |
221 | lnk = cut_bin(lnk); | 224 | lnk = cut_bin(lnk); |
222 | lnk = realloc(lnk, strlen(lnk) + 5); | 225 | lnk = realloc(lnk, strlen(lnk) + 5); |
226 | if (lnk == NULL) | ||
227 | return NULL; | ||
223 | strcat(lnk, "lib/"); /* guess "lib/" as the library dir */ | 228 | strcat(lnk, "lib/"); /* guess "lib/" as the library dir */ |
224 | return lnk; | 229 | return lnk; |
225 | } | 230 | } |
@@ -262,6 +267,8 @@ static char * get_path_from_dyld_image() { | |||
262 | path = _dyld_get_image_name(i); | 267 | path = _dyld_get_image_name(i); |
263 | if (path != NULL && strlen(path) > 0) { | 268 | if (path != NULL && strlen(path) > 0) { |
264 | p = strdup(path); | 269 | p = strdup(path); |
270 | if (p == NULL) | ||
271 | return NULL; | ||
265 | s = p + strlen(p); | 272 | s = p + strlen(p); |
266 | while ( (s > p) && (*s != '/') ) | 273 | while ( (s > p) && (*s != '/') ) |
267 | s--; | 274 | s--; |
@@ -293,7 +300,14 @@ get_path_from_PATH() { | |||
293 | if (p == NULL) | 300 | if (p == NULL) |
294 | return NULL; | 301 | return NULL; |
295 | path = strdup(p); /* because we write on it */ | 302 | path = strdup(p); /* because we write on it */ |
303 | if (path == NULL) | ||
304 | return NULL; | ||
296 | buf = malloc(strlen(path) + 20); | 305 | buf = malloc(strlen(path) + 20); |
306 | if (buf == NULL) | ||
307 | { | ||
308 | free (path); | ||
309 | return NULL; | ||
310 | } | ||
297 | size = strlen(path); | 311 | size = strlen(path); |
298 | pos = path; | 312 | pos = path; |
299 | 313 | ||
@@ -306,6 +320,8 @@ get_path_from_PATH() { | |||
306 | free(path); | 320 | free(path); |
307 | pos = cut_bin(pos); | 321 | pos = cut_bin(pos); |
308 | pos = realloc(pos, strlen(pos) + 5); | 322 | pos = realloc(pos, strlen(pos) + 5); |
323 | if (pos == NULL) | ||
324 | return NULL; | ||
309 | strcat(pos, "lib/"); | 325 | strcat(pos, "lib/"); |
310 | return pos; | 326 | return pos; |
311 | } | 327 | } |
@@ -318,6 +334,8 @@ get_path_from_PATH() { | |||
318 | free(path); | 334 | free(path); |
319 | pos = cut_bin(pos); | 335 | pos = cut_bin(pos); |
320 | pos = realloc(pos, strlen(pos) + 5); | 336 | pos = realloc(pos, strlen(pos) + 5); |
337 | if (pos == NULL) | ||
338 | return NULL; | ||
321 | strcat(pos, "lib/"); | 339 | strcat(pos, "lib/"); |
322 | return pos; | 340 | return pos; |
323 | } | 341 | } |
@@ -353,7 +371,8 @@ append_to_dir (const char *path, | |||
353 | if (fname[0] == DIR_SEPARATOR) | 371 | if (fname[0] == DIR_SEPARATOR) |
354 | fname++; | 372 | fname++; |
355 | ret = malloc (strlen (path) + strlen(fname) + 2); | 373 | ret = malloc (strlen (path) + strlen(fname) + 2); |
356 | 374 | if (ret == NULL) | |
375 | return NULL; | ||
357 | #ifdef MINGW | 376 | #ifdef MINGW |
358 | if (path[strlen(path)-1] == '\\') | 377 | if (path[strlen(path)-1] == '\\') |
359 | sprintf (ret, | 378 | sprintf (ret, |
@@ -402,6 +421,8 @@ get_installation_paths (PathProcessor pp, | |||
402 | if (p != NULL) | 421 | if (p != NULL) |
403 | { | 422 | { |
404 | d = strdup (p); | 423 | d = strdup (p); |
424 | if (d == NULL) | ||
425 | return; | ||
405 | prefix = strtok (d, ":"); | 426 | prefix = strtok (d, ":"); |
406 | while (NULL != prefix) | 427 | while (NULL != prefix) |
407 | { | 428 | { |
@@ -429,10 +450,13 @@ get_installation_paths (PathProcessor pp, | |||
429 | if (prefix == NULL) | 450 | if (prefix == NULL) |
430 | return; | 451 | return; |
431 | path = append_to_dir (prefix, PLUGINDIR); | 452 | path = append_to_dir (prefix, PLUGINDIR); |
432 | if (0 != strcmp (path, | 453 | if (path != NULL) |
433 | PLUGININSTDIR)) | 454 | { |
434 | pp (pp_cls, path); | 455 | if (0 != strcmp (path, |
435 | free (path); | 456 | PLUGININSTDIR)) |
457 | pp (pp_cls, path); | ||
458 | free (path); | ||
459 | } | ||
436 | free (prefix); | 460 | free (prefix); |
437 | } | 461 | } |
438 | 462 | ||
diff --git a/src/plugins/flv_extractor.c b/src/plugins/flv_extractor.c index 74ea283..9b72b91 100644 --- a/src/plugins/flv_extractor.c +++ b/src/plugins/flv_extractor.c | |||
@@ -784,8 +784,6 @@ static void handleASEnd(unsigned char type, void * value, void * userdata) | |||
784 | case ASTYPE_STRING: | 784 | case ASTYPE_STRING: |
785 | { | 785 | { |
786 | s = (char *)value; | 786 | s = (char *)value; |
787 | if (s != NULL) | ||
788 | s = strdup(s); | ||
789 | break; | 787 | break; |
790 | } | 788 | } |
791 | case ASTYPE_DATE: | 789 | case ASTYPE_DATE: |