projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git]
/
bfd
/
wasm-module.c
diff --git
a/bfd/wasm-module.c
b/bfd/wasm-module.c
index dfd3d873b22435a7077af69be448dcf04ebede3f..66ac2d1874b5bcb71d584772868b95d40cc5b689 100644
(file)
--- a/
bfd/wasm-module.c
+++ b/
bfd/wasm-module.c
@@
-245,6
+245,7
@@
wasm_scan_name_function_section (bfd *abfd, sec_ptr asect)
tdata_type *tdata = abfd->tdata.any;
asymbol *symbols = NULL;
sec_ptr space_function_index;
tdata_type *tdata = abfd->tdata.any;
asymbol *symbols = NULL;
sec_ptr space_function_index;
+ size_t amt;
p = asect->contents;
end = asect->contents + asect->size;
p = asect->contents;
end = asect->contents + asect->size;
@@
-301,7
+302,12
@@
wasm_scan_name_function_section (bfd *abfd, sec_ptr asect)
if (!space_function_index)
return FALSE;
if (!space_function_index)
return FALSE;
- symbols = bfd_alloc2 (abfd, tdata->symcount, sizeof (asymbol));
+ if (_bfd_mul_overflow (tdata->symcount, sizeof (asymbol), &amt))
+ {
+ bfd_set_error (bfd_error_file_too_big);
+ return FALSE;
+ }
+ symbols = bfd_alloc (abfd, amt);
if (!symbols)
return FALSE;
if (!symbols)
return FALSE;
@@
-400,30
+406,33
@@
wasm_scan (bfd *abfd)
if (bfdsec == NULL)
goto error_return;
if (bfdsec == NULL)
goto error_return;
- bfdsec->vma = vma;
- bfdsec->lma = vma;
bfdsec->size = wasm_read_leb128 (abfd, &error, &bytes_read, FALSE);
if (error)
goto error_return;
bfdsec->size = wasm_read_leb128 (abfd, &error, &bytes_read, FALSE);
if (error)
goto error_return;
- bfdsec->filepos = bfd_tell (abfd);
- bfdsec->alignment_power = 0;
}
else
{
bfd_vma payload_len;
}
else
{
bfd_vma payload_len;
- file_ptr section_start;
bfd_vma namelen;
char *name;
char *prefix = WASM_SECTION_PREFIX;
size_t prefixlen = strlen (prefix);
bfd_vma namelen;
char *name;
char *prefix = WASM_SECTION_PREFIX;
size_t prefixlen = strlen (prefix);
+ ufile_ptr filesize;
payload_len = wasm_read_leb128 (abfd, &error, &bytes_read, FALSE);
if (error)
goto error_return;
payload_len = wasm_read_leb128 (abfd, &error, &bytes_read, FALSE);
if (error)
goto error_return;
- section_start = bfd_tell (abfd);
namelen = wasm_read_leb128 (abfd, &error, &bytes_read, FALSE);
namelen = wasm_read_leb128 (abfd, &error, &bytes_read, FALSE);
- if (error || namelen > payload_len)
+ if (error || bytes_read > payload_len
+ || namelen > payload_len - bytes_read)
goto error_return;
goto error_return;
+ payload_len -= namelen + bytes_read;
+ filesize = bfd_get_file_size (abfd);
+ if (filesize != 0 && namelen > filesize)
+ {
+ bfd_set_error (bfd_error_file_truncated);
+ return FALSE;
+ }
name = bfd_alloc (abfd, namelen + prefixlen + 1);
if (!name)
goto error_return;
name = bfd_alloc (abfd, namelen + prefixlen + 1);
if (!name)
goto error_return;
@@
-437,21
+446,19
@@
wasm_scan (bfd *abfd)
if (bfdsec == NULL)
goto error_return;
if (bfdsec == NULL)
goto error_return;
- bfdsec->vma = vma;
- bfdsec->lma = vma;
- bfdsec->filepos = bfd_tell (abfd);
- bfdsec->size = section_start + payload_len - bfdsec->filepos;
- bfdsec->alignment_power = 0;
+ bfdsec->size = payload_len;
}
}
+ bfdsec->vma = vma;
+ bfdsec->lma = vma;
+ bfdsec->alignment_power = 0;
+ bfdsec->filepos = bfd_tell (abfd);
if (bfdsec->size != 0)
{
if (bfdsec->size != 0)
{
- bfdsec->contents = bfd_alloc (abfd, bfdsec->size);
+ bfdsec->contents = _bfd_alloc_and_read (abfd, bfdsec->size,
+ bfdsec->size);
if (!bfdsec->contents)
goto error_return;
if (!bfdsec->contents)
goto error_return;
-
- if (bfd_bread (bfdsec->contents, bfdsec->size, abfd) != bfdsec->size)
- goto error_return;
}
vma += bfdsec->size;
}
vma += bfdsec->size;
@@
-727,7
+734,7
@@
wasm_get_symbol_info (bfd *abfd ATTRIBUTE_UNUSED,
/* Check whether ABFD is a WebAssembly module; if so, scan it. */
/* Check whether ABFD is a WebAssembly module; if so, scan it. */
-static
const bfd_target *
+static
bfd_cleanup
wasm_object_p (bfd *abfd)
{
bfd_boolean error;
wasm_object_p (bfd *abfd)
{
bfd_boolean error;
@@
-757,7
+764,7
@@
wasm_object_p (bfd *abfd)
if (s != NULL && wasm_scan_name_function_section (abfd, s))
abfd->flags |= HAS_SYMS;
if (s != NULL && wasm_scan_name_function_section (abfd, s))
abfd->flags |= HAS_SYMS;
- return
abfd->xvec
;
+ return
_bfd_no_cleanup
;
}
/* BFD_JUMP_TABLE_WRITE */
}
/* BFD_JUMP_TABLE_WRITE */
This page took
0.025708 seconds
and
4
git commands to generate.