69 Commits

Author SHA1 Message Date
Sergi Àlvarez i Capilla
837953a1a2 Fix DoS when loading a fuzzed DEX file ##crash
* Reported by clusterfuzz
* Reproducer: bins/fuzzed/clusterfuzz-issue-44410-infloop-sample-5101731329998848
2022-02-08 14:54:24 +01:00
pancake
be248ddc1b
Fix some Leaks in Dex (#18613)
Co-authored-by: Florian Märkl <info@florianmaerkl.de>
2021-04-21 18:52:47 +02:00
pancake
a7c08c15ce Don't scream out WARNINGs, capitalizing it is enough 2021-03-19 11:02:54 +01:00
pancake
a980a1a0b0
Fix asan crash in DEX with big negative type sections (#18492) 2021-03-18 03:26:08 +01:00
pancake
08fe19ceb7 Fix asan crash found in r2_hoobr_dex_loadcode ##bin 2021-03-16 12:49:12 +01:00
ChD1
580bdf2c52
Fix some bugs in dex.c, marshal.c, panels.c and other code optimization and fixel (#18297) 2021-01-27 10:53:50 +01:00
pancake
2f2526361c Initial implementation of the DEX annotation parser ##bin 2021-01-09 17:38:54 +01:00
pancake
3ab33d119e Code cleanup and other minor refactoring changes 2021-01-09 17:38:54 +01:00
Giovanni
d7ddba55b4
Various fixes based on fuzz bins for rabin2 (#17199)
* div by 0

* null deref in r_bin_dex_free

* null deref in get_object

* memset to 0 new capacity if we increase, to avoid garbage in the vector.

* null deref in extract_sections_symbols

* printfs. and moved insert after null deref check.

* moved check before adding the cobj into list.

* moved i definition inside if.

* using r2 macros.

* changed condition to sym_size == 0

* changed condition to if (ret) do smth

* refactoring

* code formatting

* added r_pvector_new_with_len to fix issue with bad usage of RPVector

* using r_pvector_new instead DUP

* Removed check which doesn't make sense and formatting

Co-authored-by: Giovanni Dante Grazioli <giovanni.dantegrazioli@nbs-system.com>
2020-07-06 20:19:25 +08:00
Riccardo Schirone
c2b1257b59
Fix compilation warnings related to dex/bin_dex and fix some leak (#16775) 2020-05-07 11:46:09 +08:00
pancake
7df1b200a6
Reduce memory usage in DEX files by caching the getstr calls ##bin (#16706)
type    top    vsz     rss      time
------------------------------------
calloc  339M   4732640 365452   48s
pvector 338M   4731012 371484   48s // XXX fails somehow with trash indexes
htup    338M   4731556 371620   58s
nocache 350M   4742936 376156   52s
2020-04-28 16:13:20 +02:00
Liumeo
2860c4b327
Remove uleb128 code duplication (#16662)
* Replace dex_read_uleb128
* Remove dex_read_sleb128 and move dex_uleb128_len to util
2020-04-21 11:42:45 +08:00
Liumeo
b9786ac7e3
Add header guards in the include files (#16595) 2020-04-15 12:20:02 +08:00
radare
3442eb4542
Add r2 iw and rabin2 -w to enumerate try/catch blocks ##bin 2019-06-29 01:45:44 +02:00
pancake
83c50c9c26 Parse the try/catch info of methods in DEX files ##bin 2019-06-28 04:16:53 +02:00
radare
37f7052805
Handle DEX files with no entrypoint properly ##bin 2019-05-16 19:09:47 +02:00
Riccardo Schirone
66f7403245 Rewrite the RBuffer API to make it safer and adjust the codebase ##refactor (#13656)
* Reimplement r_buf_fread/fwrite
* Add slice buffer and introduce readonly field
* Do nothing if size is 0
* Prevents an overflow when 8 is subtracted from size.
* Fix ragg2 when patching outside currently existing buffer
* Implement r_mem_mmap_resize for systems where mremap is not defined
* r_buf_buffer can be called with no size arg as well
* Use size_t instead of ut64
2019-05-15 15:34:06 +02:00
Riccardo Schirone
3f4580b031
Make buf field private in RBuffer (#13473)
* Fix pemixed build (and include it in meson build)
* Do not use base_priv in yank, it was wrongly used.
2019-03-26 20:32:53 +01:00
Riccardo Schirone
0948f9536b
Use r_buf_size to get the size of a buffer, not the private field (#13380)
* Use r_buf_size to get the size of a buffer, not the private field
* Use r_buf_seek instead of adjusting the private cur RBuffer field
* use r_buf_read instead of r_buf_read_at(.., cur, ..)
* Fix RBuffer usage in REgg
* Introduce r_buf_tell API instead of using seek
* write_at(cur) == write
2019-03-15 20:28:52 +01:00
Riccardo Schirone
449e081db8 Rbin remove old load_bytes callbacks ##bin
* bin_bootimg: load_buffer/check_buffer
* bin_cgc/bin_elf/bin_elf64: remove load_bytes/load + load_buffer
* Implement check_buffer in bin_cgc
* bin_coff: load_buffer/check_buffer
* bin_dex: load_buffer/check_buffer
* bin_dol: load_buffer/check_buffer
* bin_dyldcache: load_buffer/check_buffer
2019-03-13 12:15:23 +01:00
Neven Sajko
d8784641ee Add parentheses in macros where needed for safety (#11290) 2018-08-30 13:16:50 +02:00
Fangrui Song
2ea5f62d14 Remove #pragma pack to suppress -Wpragma-pack-suspicious-include (#11114)
These structs are defined in the way that no #pragma pack is needed.
2018-08-18 03:43:46 +02:00
Marc
2d2b7c9859 Add load_buffer in Dex (#9892) 2018-04-16 00:32:46 +02:00
pancake
22fe9106ec Fix #8734 - Optimize a loop in DEX from infinite to 3s 2017-10-24 17:54:01 +02:00
Marc
6aec198df7 Add DEX38 support 2017-08-01 05:00:48 +02:00
Marc
1c772a9672 Enhance icj, ic and id in Dex (#7821) 2017-06-27 17:02:14 +02:00
radare
f0e1d77a40 Fix the DEX crash regression with invalid method names (#7635) 2017-05-30 15:44:57 +02:00
Marc
eeb3da8c8b Fix some covs in DEX 2017-04-11 11:28:12 +02:00
alvarofe
a5c13c464a Fix #6905 - oob read in dex
Added new size parameter into uleb functions
2017-03-05 12:45:06 +01:00
Marc
459fc39f5b Add debug info support for Dalvik (#6570) 2017-01-24 18:51:27 +01:00
Marc
c585f91439 Dalvik analysis and bin parsing enhancements (#6320)
* Initial work to enhance the dalvik analysis with rbin info
* fix ptr addr in new-instance instruction in Dalvik Anal (#6082)
* dalvik anal:fix ptr addr in new-instance
* first ESIL instructions for Dalvik
* more ESIL instructions for Dalvik
* parse more data in dex format
* code refactor and several fixes
2016-12-15 00:14:33 +01:00
pancake
ea5c83ce4e Fix a bunch of malloc(0) 2016-11-08 15:09:52 +01:00
Álvaro Felipe Melchor
4d3e687657 Fix #6121 #6120 - fix oob read on dex parser 2016-11-04 23:08:33 +01:00
Marc
c0c0cba339 fix #5465, #5745, 'ic' command and some memory leaks (#5764) 2016-09-14 21:49:03 +02:00
Marc
a76977a895 Enhance DEX parser 2016-09-09 19:27:36 +02:00
pancake
0e39492148 Make dalvik method/field names consistent again 2016-08-28 13:53:59 +02:00
pancake
0b32cf7c90 Fix recent regressions for DEX, fix entrypoints, {s,i}fields and lot of segfaults! 2016-08-28 13:19:04 +02:00
Damien Zammit
e9e8ae3629 Bigendian fixes: DEX parser (#5588) 2016-08-27 01:34:45 +02:00
pancake
bc0f5fe119 Parse fields and statics in DEX 2016-08-06 03:10:56 +02:00
pancake
cc01682132 Some playground with DEX 2016-08-05 13:11:30 +02:00
pancake
e553fc2bec Fix method names glitch in DEX 2016-08-05 00:27:01 +02:00
Álvaro Felipe Melchor
95db0cee52 Fix oob 52961b39cfb9782c336c8a8247a6317f by revskills 2016-06-28 23:50:41 +02:00
Álvaro Felipe Melchor
fe0ea49a6f Fix #4577 - thx @revskills 2016-04-09 13:01:15 +02:00
pancake
b10aa5a0a2 Initial support for loading Android ART binaries 2015-06-17 11:14:41 +02:00
pancake
a295e9a6d5 Enforce DEX null checks and fix fuzz regressions 2015-05-11 20:21:08 +02:00
pancake
53cad19e1b Fix id053 fuzzed DEX crash 2015-05-07 02:17:08 +02:00
condret
375427cb8c fix 2 warnings, low hanging tits 2015-04-08 13:20:26 +02:00
ninjahacker
d1351cf836 Added initial zimg support 2015-04-06 22:31:06 -04:00
pancake
0b04317bdb Sdb memoization in RBin speedups DEX loading
Avoid some memdupping in the dex parser - needs more work
2015-04-06 00:59:55 +02:00
pancake
33fcd7fbcf Enhacements for DEX sections and ignore methods at 0 (wip) 2015-02-06 18:53:11 +01:00