mirror of https://github.com/google/oss-fuzz.git
Don't leak in binutils test infrastructure (#7874)
Using bfd_check_format_matches requires that a returned matching vector (when return is false and bfd_get_error() is bfd_error_file_ambiguously_recognized) be freed. Use bfd_check_format instead.
This commit is contained in:
parent
d288c9ae86
commit
4b60b6fd06
|
@ -32,8 +32,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
bfd *file;
|
bfd *file;
|
||||||
file = bfd_openr (filename, NULL);
|
file = bfd_openr (filename, NULL);
|
||||||
if (file) {
|
if (file) {
|
||||||
char **matches;
|
if (bfd_check_format (file, bfd_object)) {
|
||||||
if (bfd_check_format_matches (file, bfd_object, &matches)) {
|
|
||||||
load_separate_debug_files(file, bfd_get_filename(file));
|
load_separate_debug_files(file, bfd_get_filename(file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
|
|
||||||
int f;
|
int f;
|
||||||
bfd *arch;
|
bfd *arch;
|
||||||
char **matching;
|
|
||||||
|
|
||||||
f = open (filename, O_RDWR | O_BINARY, 0);
|
f = open (filename, O_RDWR | O_BINARY, 0);
|
||||||
if (f < 0) {
|
if (f < 0) {
|
||||||
|
@ -55,7 +54,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
close(f);
|
close(f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (! bfd_check_format_matches (arch, bfd_archive, &matching)) {
|
if (! bfd_check_format (arch, bfd_archive)) {
|
||||||
bfd_close(arch);
|
bfd_close(arch);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ fuzz_check_coff_rsrc (const char *filename, const char *target)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! bfd_check_format_matches (abfd, bfd_object, NULL)) {
|
if (! bfd_check_format (abfd, bfd_object)) {
|
||||||
retval = 0;
|
retval = 0;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue