Commit Graph

48 Commits

Author SHA1 Message Date
Rot127 3a2cd3c331
Coverity defects (#2469)
* Fix CID 508418 - Uninitialized struct

* Fix CID 509089 - Fix OOB read and write

* Fix CID 509088 - OOB.

Also adds tests and to ensure no OOB access.

* Fix CID 509085 - Resource leak.

* Fix CID 508414 and companions - Using undefined values.

* Fix CID 508405 - Use of uninitialized value

* Remove unnecessary and badly implemented dev fuzz code.

* Fix CID 508396 - Uninitialzied variable.

* Fix CID 508393, 508365 -- OOB read.

* Fix CID 432207 - OVerlapping memory access.

* Remove unused functions

* Fix CID 432170 - Overlapping memory access.

* Fix CID 166022 - Check for negative index

* Let strncat not depend n src operand.

* Fix 509083 and 509084 - NULL dereference

* Remove duplicated code.

* Initialize sysop

* Fix resource leak

* Remove unreachable code.

* Remove duplicate code.

* Add assert to check return value of cmoack

* Fixed: d should be a signed value, since it is checked against < 0

* Add missing break.

* Add NULL check

* Fix signs of binary search comparisons.

* Add explicit cast of or result

* Fix correct scope of case.

* Handle invalid integer type.

* Return UINT_MAX instead of implicitly casted -1

* Remove dead code

* Fix type of im

* Fix type of d

* Remove duplicated code.

* Add returns after CS_ASSERTS

* Check for len == 0 case.

* Ensure shift operates on uint64

* Replace strcpy with strncpy.

* Handle edge cases for 32bit rotate

* Fix some out of enum warnings

* Replace a strcpy with strncpy.

* Fix increment of address

* Skip some linting

* Fix: set instruction id

* Remove unused enum

* Replace the last usages of strcpy with SStream functions.

* Increase number of allowed AArch64 operands.

* Check safety of incrementing t the next operand.

* Fix naming of operand

* Update python constants

* Fix option setup of CS_OPT_DETAIL_REAL

* Document DETAIL_REAL has to be used with CS_OPT_ON.

* Run Coverity scan every Monday.

* Remove dead code

* Fix OOB read

* Rename macro to reflect it is only used with sstreams

* Fix rebase issues
2024-09-18 21:19:42 +08:00
Rot127 af1ed2fb3d
SystemZ Auto-Sync refactor (#2462) 2024-09-14 16:57:54 +08:00
Rot127 926cfebd6b Architecture updater (auto-sync) - Updating PPC (#2013) 2023-09-05 12:24:59 +08:00
Rot127 104f693c11 Architecture updater (auto-sync) - Updating ARM (#1949)
* Add auto-sync updater.

* Update Capstone core with auto-sync changes.

* Update ARM via auto-sync.

* Make changes to arch modules which are introduced by auto-sync.

* Update tests for ARM.

* Fix build warnings for make

* Remove meson.build

* Print shift amount in decimal

* Patch non LLVM register alias.

* Change type of immediate operand to unsiged (due to: #771)

* Replace all occurances of a register with its alias.

* Fix printing of signed imms

* Print rotate amount in decimal

* CHange imm type to int64_t to match LLVM imm type.

* Fix search for register names, by completing string first.

* Print ModImm operands always in decimal

* Use number format of previous capstone version.

* Correct implicit writes and update_flags according to SBit.

* Add missing test for RegImmShift

* Reverse incorrect comparision.

* Set shift information for move instructions.

* Set mem access for all memory operands

* Set subtracted flag if offset is negative.

* Add flag for post-index memory operands.

* Add detail op for BX_RET and MOVPCLR

* Use instruction post_index operand.

* Add VPOP and VPUSH as unique CS IDs.

* Add shifting info for MOVsr.

* Add TODOs.

* Add in LLVM hardcoded operands to detail.

* Move detail editing from InstPrinter to Mapping

* Formatting

* Add removed check.

* Add writeback register and constraints to RFEI instructions.

* Translate shift immediate

* Print negative immediates

* Remove duplicate invalid entry

* Add CS groups to instructions

* Fix write attriutes of stores.

* Add missing names of added instructions

* Fix LLVM bug

* Add more post_index flags

* http -> https

* Make generated functions static

* Remove tab prefix for alias instructions.

* Set ValidateMCOperand to NULL.

* Fix AddrMode3Operand operands

* Allow getting system and banked register name via API

* Add writeback to STC/LDC instructions.

* Fix (hopefully) last case where disp is negative and subtracted = true

* Remove accidentially introduced regressions
2023-07-19 17:56:27 +08:00
Nguyen Anh Quynh b543c345ca ppc: sync with llvm 7.0.1 2019-04-30 13:50:42 +08:00
Nguyen Anh Quynh f407e94249 arm64: sync with LLVM 7.0.1 2019-04-10 14:17:08 +08:00
Nguyen Anh Quynh 3dcdcfa713 sync with LLVM 7.0.1. X86 is first 2019-02-26 15:19:51 +08:00
Catena cyber 31f8e8e0be Avoid overflow in SStream.c (#1381) 2019-02-15 08:18:31 +08:00
Spike 55f242d498 Add webassembly arch (#1359)
* add wasm arch

* fix bug

* delete todo & add wasm into readme
2019-02-01 23:03:47 +08:00
Nguyen Anh Quynh 76c1c3c4e9 merge next to master 2018-07-20 12:36:50 +08:00
vit9696 c2514aab00 Add Availability.h include to fix macOS SDK instrinsics 2018-06-15 22:14:48 +08:00
vit9696 f52aa1f39c Add Availability.h include to fix macOS SDK instrinsics (#1175) 2018-06-14 22:12:26 +01:00
vit9696 c0943009a9 macOS kernel has no limits.h but i386/limits.h (#1172) 2018-06-13 22:59:39 +01:00
vit9696 6625328843 macOS kernel has no limits.h but i386/limits.h (#1172) 2018-06-13 22:14:19 +08:00
Catena cyber 0b3136e7fe Print right hex value for MIN_INT (#1160) 2018-06-02 22:20:13 +08:00
Catena cyber 93ba399855 Print right hex value for MIN_INT (#1155) 2018-06-02 16:55:05 +08:00
Nguyen Anh Quynh 3a6ea8a998 SStream.c needs limits.h 2018-04-03 23:02:11 +08:00
Nguyen Anh Quynh 491ebcdc19 indentation fix 2018-04-03 22:44:46 +08:00
Nguyen Anh Quynh c34b423693 indentation 2018-04-03 22:30:27 +08:00
Google AutoFuzz Team 450ed8ad52 Fixing #1060
Adding to the fixes submitted in commit 5b55115c42
2018-03-22 15:41:30 -07:00
Nguyen Anh Quynh 2a00340ddb fix signed int overflow reported by Google AutoFuzz at #1060, #1061, #1062 2017-12-15 10:17:56 +08:00
Richard Henderson 5423b215bf Constify backend data (#1040)
* Constify string literals

Use -Wwrite-strings to force string literals to be of
type "const char[]", then fix up all warning fallout.

* Constify common infrastructure

Step one in allowing backend data to be readonly.
Minimal changes to backends for now; just set all pointers
in common structs that aren't modified to const.

* Constify AArch64 backend

Section size changes within libcapstone.so are

-.rodata               602587
-.data.rel.ro          228416
-.data                1003746
+.rodata               769051
+.data.rel.ro          241120
+.data                 824578

* Constify ARM backend

Section size changes within libcapstone.so are

-.rodata               769051
-.data.rel.ro          241120
-.data                 824578
+.rodata               959835
+.data.rel.ro          245120
+.data                 629506

* Constify Mips backend

Section size changes within libcapstone.so are

-.rodata               959835
-.data.rel.ro          245120
-.data                 629506
+.rodata              1069851
+.data.rel.ro          256416
+.data                 508194

* Constify PowerPC backend

Section size changes within libcapstone.so are

-.rodata              1069851
-.data.rel.ro          256416
-.data                 508194
+.rodata              1142715
+.data.rel.ro          272224
+.data                 419490

* Constify Sparc backend

Section size changes within libcapstone.so are

-.rodata              1142715
-.data.rel.ro          272224
-.data                 419490
+.rodata              1175227
+.data.rel.ro          277536
+.data                 381666

* Constify SystemZ backend

Section size changes within libcapstone.so are

-.rodata              1175227
-.data.rel.ro          277536
-.data                 381666
+.rodata              1221883
+.data.rel.ro          278016
+.data                 334498

* Constify X86 backend

Section size changes within libcapstone.so are

-.rodata              1221883
-.data.rel.ro          278016
-.data                 334498
+.rodata              1533531
+.data.rel.ro          281184
+.data                  19714

* Constify XCore backend

Section size changes within libcapstone.so are

-.rodata              1533531
-.data.rel.ro          281184
-.data                  19714
+.rodata              1553026
+.data.rel.ro          281280
+.data                     40
2017-10-22 08:45:40 +08:00
tandasat e36384e224 Merge remote-tracking branch 'upstream/next' into next 2016-05-11 22:52:34 -07:00
tandasat d4ef430b33 port Windows driver support 2016-05-11 21:48:32 -07:00
Nguyen Anh Quynh 3f461adae3 remove myinttypes.h 2016-04-26 09:47:30 +08:00
tandasat 152c1baf9f skip stdint.h for windows driver configuration 2016-04-23 15:58:31 -07:00
Koutheir Attouchi 9f2070748c Added support for building binaries for Windows CE 7 on ARMv7 (a.k.a., Windows Embedded Compact 7) and for Windows CE 8 on ARMv7 (a.k.a., Windows Embedded Compact 2013).
Added support for building binaries for Windows CE 7 on ARMv7 (a.k.a., Windows Embedded Compact 7) and for Windows CE 8 on ARMv7 (a.k.a., Windows Embedded Compact 2013).

Added support for building binaries for Windows CE 7 on ARMv7 (a.k.a., Windows Embedded Compact 7) and for Windows CE 8 on ARMv7 (a.k.a., Windows Embedded Compact 2013).

Replaced header inclusions of "stdint.h" and "intrin.h" by selective inclusions to support platforms that do not provide those headers. The header "platform.h" handles the platform test.
Updated the build script for Windows CE 7 on ARMv7.
2016-04-07 17:05:00 +02:00
reverser cf6201419a Add support to embed Capstone into OS X kernel extensions. 2015-04-10 23:28:12 +08:00
reverser 160e198584 Add support to embed Capstone 3.x branch into OS X kernel extensions. 2015-04-09 18:28:19 +01:00
Cr4sh 19ee2d10b3 inttypes.h fix 2015-03-29 21:16:38 +08:00
Cr4sh 9d60607645 inttypes.h fix 2015-03-29 18:29:06 +08:00
Nguyen Anh Quynh bfcaba5851 2015 2015-03-04 17:45:23 +08:00
Nguyen Anh Quynh 03a1836454 arm64: set absolute (rather than relative) address B/BL. issue reported by Pancake 2014-12-12 22:06:06 +08:00
Nguyen Anh Quynh c109e8eef3 arm64: print shifter in decimal mode. this is to be consistent with ARM engine 2014-11-08 13:58:50 +08:00
flyingsymbols d91f964d40 * Fixed bug in Thumb2 pop caused by me incorrectly assuming that
ARM_SP == 13, ARM_LR == 14, and ARM_PC == 15, which is not the case
* updated CMakeLists to include building arm regression test
* added explicit casts for 64 bit visual studio 2012 build to get around
  truncation warnings from size_t conversion
2014-10-23 12:04:23 -04:00
Nguyen Anh Quynh ea3c089591 some simple optimizations for speed. this improves performance about 5% 2014-10-02 10:17:55 +08:00
Yegor Derevenets ced9d24e35 Workaround missing <inttypes.h> on MSVC 2010 2014-09-21 17:27:11 +02:00
Nguyen Anh Quynh 46a74e53b7 arm64: update core. this added a lot more details to cs_arm64_op struct 2014-08-25 16:47:12 +08:00
flyingsymbols 298d413bbc * added a test file to suite for testing invalid and valid instruction sequences
* fixed and added a test for a thumb-2 invalid sequence that was incorrectly allowed before these changes (pop.w with sp argument included)
* fixed and added a test for a blx from thumb to ARM that had its immediate argument incorrect (misaligned)

* eliminated some warnings by explicitly casting so I could turn on
  treat warnings as errors locally

General notes:
*  probably worth turning on treat all warnings as errors in the msvc project files, had a subtle bug that resulted from a missing declaration causing differences in dll and static compilation modes

( code was working incorrectly in dll form because of missing declaration in arch/ARM/ARMMapping.h for new function ARM_blx_to_arm_mode. Something about the linking was confusing ld when making the dll, and the resulting offsets were wonky (e.g. the added ble test would show up as #0x1fc instead of #0x1fe like it should have )

* the invalid pop was being treated as a soft fail which then gets coerced
  to a success because it is != MCDisassembler_Fail in Thumb_getInstruction
  what are the semantics of a soft fail? Maybe we should be able to set up
  whether or not we want a soft fail to be a real fail in the csh struct?
2014-07-15 04:33:40 -04:00
Nguyen Anh Quynh 476d5ad7a5 msvc: disable warning on strcpy() 2014-06-17 15:09:59 +08:00
Nguyen Anh Quynh b76233c648 avoid using vsnprintf when possible for SStream_concat() to improve performance. based on the idea of Dang Hoang Vu. 2014-06-04 18:31:02 +08:00
Nguyen Anh Quynh bb0744df5d do not initialize some local vars unnecessarily. this problem was introduced when we fixed C89 issues for MSVC 2014-05-12 13:41:49 +08:00
Nguyen Anh Quynh 42706a39e2 indentation with tab 2014-05-09 07:33:35 +08:00
Axel 0vercl0k Souchet 779d4c75d9 first changes to get a successfully compiled version of capstone on VS2012 2014-05-08 23:44:49 +01:00
Nguyen Anh Quynh 6023ef7843 Disassembler -> Disassembly 2014-04-29 11:21:04 +08:00
Nguyen Anh Quynh fc83a439e5 add diet compile option (CAPSTONE_DIET option in config.mk). This reduces binary size by around 40% 2014-02-22 23:26:27 +08:00
Nguyen Anh Quynh edeeb04a1a make vsnprintf() user-defined function pointer, which is passed in via the same CS_OPT_MEM option like malloc/calloc etc 2014-01-15 20:44:03 +08:00
Nguyen Anh Quynh 26ee41aa67 initial import 2013-11-27 12:11:31 +08:00