From 73cc634ba73640a6016da9483414dbffdfc84811 Mon Sep 17 00:00:00 2001 From: PauRE Date: Sun, 13 Feb 2022 02:04:17 +0100 Subject: [PATCH 001/390] Partial #19687: Add release github actions workflow ##ci * Add release github actions workflow --- .github/workflows/release.yml | 185 ++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000000..9c18f8610062a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,185 @@ +name: release +on: + push: + tags: + - '*.*.*' +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Extract r2 version + run: echo "##[set-output name=branch;]$( cd sys;python version.py )" + id: r2v + - name: Prepare release notes + run: ./sys/release-notes.sh | tee ./RELEASE_NOTES.md + - name: Download artifacts + env: + REPO: ${{ github.repository }} + COMMIT: ${{ github.sha }} + DESTDIR: dist/artifacts + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + RUN_ID=`gh run --repo "${REPO}" list --workflow "ci.yml" --json "databaseId,status,headSha" --jq '.[] | select(.status=="completed" and .headSha=="'"${COMMIT}"'") | .databaseId'` + gh run --repo "${REPO}" download "${RUN_ID}" --dir "${DESTDIR}" + RUN_ID=`gh run --repo "${REPO}" list --workflow "windows.yml" --json "databaseId,status,headSha" --jq '.[] | select(.status=="completed" and .headSha=="'"${COMMIT}"'") | .databaseId'` + gh run --repo "${REPO}" download "${RUN_ID}" --dir "${DESTDIR}" + RUN_ID=`gh run --repo "${REPO}" list --workflow "freebsd.yml" --json "databaseId,status,headSha" --jq '.[] | select(.status=="completed" and .headSha=="'"${COMMIT}"'") | .databaseId'` + gh run --repo "${REPO}" download "${RUN_ID}" --dir "${DESTDIR}" + find "${DESTDIR}" -type f + - name: Create GitHub release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + body_path: ./RELEASE_NOTES.md + draft: false + prerelease: false + - name: Upload asset for Debian (amd64) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/radare2_${{ steps.r2v.outputs.branch }}-debian_amd64.zip/radare2/radare2_${{ steps.r2v.outputs.branch }}_amd64.deb + asset_name: radare2_${{ steps.r2v.outputs.branch }}_amd64.deb + asset_content_type: application/vnd.debian.binary-package + - name: Upload asset for Debian (i386) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/radare2_${{ steps.r2v.outputs.branch }}-debian_i386.zip/radare2/radare2_${{ steps.r2v.outputs.branch }}_i386.deb + asset_name: radare2_${{ steps.r2v.outputs.branch }}_i386.deb + asset_content_type: application/vnd.debian.binary-package + - name: Upload asset for Windows (w64) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/artifact/radare2-${{ steps.r2v.outputs.branch }}-w64.zip + asset_name: radare2-${{ steps.r2v.outputs.branch }}-w64.zip + asset_content_type: application/zip + - name: Upload asset for Windows (w32) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}-w32.zip/radare2-${{ steps.r2v.outputs.branch }}-w32.zip + asset_name: radare2-${{ steps.r2v.outputs.branch }}-w32.zip + asset_content_type: application/zip + - name: Upload asset for macOS + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}_macos.pkg/radare2-${{ steps.r2v.outputs.branch }}.pkg + asset_name: radare2-${{ steps.r2v.outputs.branch }}.pkg + asset_content_type: application/x-xar + - name: Upload asset for iPhoneOS (arm) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}_iphoneos-arm64.zip/radare2/radare2_${{ steps.r2v.outputs.branch }}_iphoneos-arm.deb + asset_name: radare2_${{ steps.r2v.outputs.branch }}_iphoneos-arm.deb + asset_content_type: application/vnd.debian.binary-package + - name: Upload asset for iPhoneOS (arm32) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/radare2-arm32_${{ steps.r2v.outputs.branch }}_iphoneos-arm/radare2-arm32_${{ steps.r2v.outputs.branch }}_iphoneos-arm.deb + asset_name: radare2-arm32_${{ steps.r2v.outputs.branch }}_iphoneos-arm.deb + asset_content_type: application/vnd.debian.binary-package + - name: Upload asset for iOS SDK + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/r2ios_sdk-${{ steps.r2v.outputs.branch }}.zip/r2ios-sdk.zip + asset_name: r2ios-sdk-${{ steps.r2v.outputs.branch }}.zip + asset_content_type: application/zip + - name: Upload asset for Android (arm) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}-android-arm.tar.gz/radare2-${{ steps.r2v.outputs.branch }}-android-arm.tar.gz + asset_name: radare2-${{ steps.r2v.outputs.branch }}-android-arm.tar.gz + asset_content_type: application/gzip + - name: Upload asset for Android (x86_64) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}-android-x86_64.tar.gz/radare2-android-x86_64.tar.gz + asset_name: radare2-${{ steps.r2v.outputs.branch }}-android-x86_64.tar.gz + asset_content_type: application/x-tar + - name: Upload asset for Android (aarch64) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}-android-aarch64.tar.gz/radare2-${{ steps.r2v.outputs.branch }}-android-aarch64.tar.gz + asset_name: radare2-${{ steps.r2v.outputs.branch }}-android-aarch64.tar.gz + asset_content_type: application/gzip + - name: Upload asset for Linux (static) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}-static.tar.xz/r2-static.tar.xz + asset_name: radare2-${{ steps.r2v.outputs.branch }}-static.tar.xz + asset_content_type: application/x-xz + - name: Upload asset for Debian dev (amd64) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/radare2_${{ steps.r2v.outputs.branch }}-debian_amd64.zip/radare2-dev/radare2-dev_${{ steps.r2v.outputs.branch }}_amd64.deb + asset_name: radare2-dev_${{ steps.r2v.outputs.branch }}_amd64.deb + asset_content_type: application/vnd.debian.binary-package + - name: Upload asset for Debian dev (i386) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/radare2_${{ steps.r2v.outputs.branch }}-debian_i386.zip/radare2-dev/radare2-dev_${{ steps.r2v.outputs.branch }}_i386.deb + asset_name: radare2-dev_${{ steps.r2v.outputs.branch }}_i386.deb + asset_content_type: application/vnd.debian.binary-package + - name: Upload asset for WASI + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}-wasi.zip/radare2-${{ steps.r2v.outputs.branch }}-wasi.zip + asset_name: radare2-${{ steps.r2v.outputs.branch }}-wasi.zip + asset_content_type: application/zip + - name: Upload asset for FreeBSD + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/artifacts/artifact/radare2-freebsd.tgz + asset_name: radare2-${{ steps.r2v.outputs.branch }}-freebsd.tgz + asset_content_type: application/gzip From dbc7606eda3c7dd7379ae60b106126a46550e676 Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Sun, 13 Feb 2022 17:54:23 +0100 Subject: [PATCH 002/390] Allow to override build date with SOURCE_DATE_EPOCH in order to make builds reproducible. See https://reproducible-builds.org/ for why this is good and https://reproducible-builds.org/specs/source-date-epoch/ for the definition of this variable. This date call only works with GNU date. Also use UTC to be independent of timezone. This is the equivalent of 6b260b87c3345568ebeddf57fbe95c864ee8baf2 for meson. This PR was done while working on reproducible builds for openSUSE. --- meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index ce136c92f6418..645378b975152 100644 --- a/meson.build +++ b/meson.build @@ -72,7 +72,11 @@ endif if host_machine.system() == 'windows' r2birth = run_command('cmd', '/c', 'echo %date%__%time%') else - r2birth = run_command('date', '+%Y-%m-%d__%H:%M:%S') + source_date_epoch = run_command('sh', '-c', 'echo $SOURCE_DATE_EPOCH').stdout().strip() + if source_date_epoch == '' + source_date_epoch = run_command('date', '+%s').stdout().strip() + endif + r2birth = run_command('date', '-u', '-d', '@' + source_date_epoch, '+%Y-%m-%d__%H:%M:%S') endif if r2birth.returncode() != 0 r2birth = '' From d843f078a00a760a5e05dd5429e147eb043f08c1 Mon Sep 17 00:00:00 2001 From: Dennis Goodlett Date: Sun, 13 Feb 2022 16:16:03 -0500 Subject: [PATCH 003/390] Prevent leak when jumptable has size hint --- libr/anal/jmptbl.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libr/anal/jmptbl.c b/libr/anal/jmptbl.c index cb848b7c1087f..4864590e3b9b7 100644 --- a/libr/anal/jmptbl.c +++ b/libr/anal/jmptbl.c @@ -455,15 +455,6 @@ R_API bool try_get_jmptbl_info(RAnal *anal, RAnalFunction *fcn, ut64 addr, RAnal // default case is the jump target of the unconditional jump *default_case = prev_bb->jump == my_bb->addr ? prev_bb->fail : prev_bb->jump; - RAnalOp tmp_aop = {0}; - ut8 *bb_buf = calloc (1, prev_bb->size); - if (!bb_buf) { - return false; - } - // search for a cmp register with a reasonable size - anal->iob.read_at (anal->iob.io, prev_bb->addr, (ut8 *) bb_buf, prev_bb->size); - isValid = false; - RAnalHint *hint = r_anal_hint_get (anal, addr); if (hint) { ut64 val = hint->val; @@ -474,6 +465,15 @@ R_API bool try_get_jmptbl_info(RAnal *anal, RAnalFunction *fcn, ut64 addr, RAnal } } + RAnalOp tmp_aop = {0}; + ut8 *bb_buf = calloc (1, prev_bb->size); + if (!bb_buf) { + return false; + } + // search for a cmp register with a reasonable size + anal->iob.read_at (anal->iob.io, prev_bb->addr, (ut8 *) bb_buf, prev_bb->size); + isValid = false; + RRegItem *cmp_reg = NULL; for (i = prev_bb->ninstr - 1; i >= 0; i--) { const ut64 prev_pos = r_anal_bb_offset_inst (prev_bb, i); From b5cb90b28ec71fda3504da04e3cc94a362807f5e Mon Sep 17 00:00:00 2001 From: pancake Date: Sun, 13 Feb 2022 21:27:58 +0100 Subject: [PATCH 004/390] Prefer memleak over usaf in io.bank's rbtree bug ##crash * That's a workaround, proper fix will come later * Reproducer: bins/fuzzed/iobank-crash * Reported by Akyne Choi via huntr.dev --- libr/io/io_bank.c | 8 +++++++- libr/util/new_rbtree.c | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libr/io/io_bank.c b/libr/io/io_bank.c index 882dfc48d18f0..91f3bd1764eea 100644 --- a/libr/io/io_bank.c +++ b/libr/io/io_bank.c @@ -226,12 +226,18 @@ R_API bool r_io_bank_map_add_top(RIO *io, const ut32 bankid, const ut32 mapid) { r_io_submap_set_to (bd, r_io_submap_from (sm) - 1); entry = r_rbnode_next (entry); } - while (entry && r_io_submap_to (((RIOSubMap *)entry->data)) <= r_io_submap_to (sm)) { + ut64 smto = r_io_submap_to (sm); + while (entry && r_io_submap_to (((RIOSubMap *)entry->data)) <= smto) { //delete all submaps that are completly included in sm RRBNode *next = r_rbnode_next (entry); // this can be optimized, there is no need to do search here + // XXX this is a workaround to avoid an UAF in Reproducer: iobank-crash + void *smfree = bank->submaps->free; + bank->submaps->free = NULL; bool a = r_crbtree_delete (bank->submaps, entry->data, _find_sm_by_from_vaddr_cb, NULL); + bank->submaps->free = smfree; if (!a) { + entry = NULL; break; } entry = next; diff --git a/libr/util/new_rbtree.c b/libr/util/new_rbtree.c index a40c44b00d745..2b720a15db08a 100644 --- a/libr/util/new_rbtree.c +++ b/libr/util/new_rbtree.c @@ -138,9 +138,9 @@ R_API bool r_crbtree_insert(RRBTree *tree, void *data, RRBComparator cmp, void * r_return_val_if_fail (tree && data && cmp, false); bool inserted = false; - if (tree->root == NULL) { + if (!tree->root) { tree->root = _node_new (data, NULL); - if (tree->root == NULL) { + if (!tree->root) { return false; } inserted = true; From 83e23ac9af6c0a3d32a0a5f0deb0fded098fd244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20=C3=80lvarez=20i=20Capilla?= Date: Sun, 13 Feb 2022 23:01:08 +0100 Subject: [PATCH 005/390] Fix ghosty allocation --- libr/core/cmd_print.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index 5151d113c703e..65e5ae3bc3270 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -5225,7 +5225,9 @@ static int cmd_print(void *data, const char *input) { } } } - + if (len < 0) { + len = -len; + } if (len > core->blocksize) { block = calloc (1, len); if (block) { From 4145077fb97dc5075aa9dc14291d065f24ad0476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20=C3=80lvarez=20i=20Capilla?= Date: Sun, 13 Feb 2022 22:03:00 +0100 Subject: [PATCH 006/390] Fix ihex:// io parser somehow not working ##io --- libr/io/p/io_ihex.c | 73 +++++++++++++++++++++++---------------------- test/db/io/ihex | 28 +++++++++++++++++ 2 files changed, 66 insertions(+), 35 deletions(-) diff --git a/libr/io/p/io_ihex.c b/libr/io/p/io_ihex.c index 662118eb9ff43..38a5d78b08417 100644 --- a/libr/io/p/io_ihex.c +++ b/libr/io/p/io_ihex.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2013-2017 - pancake, fenugrec */ +/* radare - LGPL - Copyright 2013-2022 - pancake, fenugrec */ /* *** .hex format description : every line follows this pattern @@ -25,13 +25,7 @@ KK = 0 - (sum of all bytes) */ -#include "r_io.h" -#include "r_lib.h" -#include "r_util.h" -#include //for INT_MAX -#include -#include -#include +#include //struct Rihex : holds sparse buffer + its own fd, for internal management typedef struct { @@ -181,7 +175,6 @@ static int fwblock(FILE *fd, ut8 *b, ut32 start_addr, ut16 size) { static int fw04b(FILE *fd, ut16 eaddr) { ut8 cks = 0 - (6 + (eaddr >> 8) + (eaddr & 0xff)); return fprintf (fd, ":02000004%04X%02X\n", eaddr, cks); - } static int __read(RIO *io, RIODesc *fd, ut8 *buf, int count) { @@ -251,6 +244,7 @@ static bool ihex_parse(RBuffer *rbuf, char *str) { bc &= 0xff; addr_tmp &= 0xffff; type &= 0xff; + ut64 at = (!sec_start && sec_start == addr_tmp)? addr_tmp? addr_tmp:sec_start: sec_start + addr_tmp; switch (type) { case 0: // DATA @@ -259,40 +253,48 @@ static bool ihex_parse(RBuffer *rbuf, char *str) { *eol = 0; } cksum = bc; - cksum += addr_tmp>>8; + cksum += addr_tmp >> 8; cksum += addr_tmp; cksum += type; - if ((next_addr != addr_tmp) || ((sec_size + bc) > SEC_MAX)) { + for (i = 0; i < bc; i++) { + if (sscanf (str + 9 + (i * 2), "%02x", &byte) != 1) { + eprintf ("unparsable data (%s)!\n", str); + goto fail; + } +// eprintf ("SEC(%02x)", byte); + if (sec_size + i < sec_count) { + sec_tmp[i] = (ut8) byte & 0xff; + } + cksum += byte; + } + if (1) { // || (next_addr != addr_tmp) || ((sec_size + bc) > SEC_MAX)) { //previous block is not contiguous, or //section buffer is full => write a sparse chunk - if (sec_size && sec_size < UT16_MAX) { - if (r_buf_write_at (rbuf, sec_start, sec_tmp, (int) sec_size) != sec_size) { - eprintf ("sparse buffer problem, giving up\n"); - goto fail; - } + //if (sec_size && sec_size < UT16_MAX) { + sec_size = bc; + ut32 tmp = 0; + r_buf_read_at (rbuf, at, (ut8*)&tmp, 4); + if (tmp && tmp != UT32_MAX) { + eprintf ("Cannot write%c", 10); + return true; } + if (r_buf_write_at (rbuf, at, sec_tmp, sec_size) != sec_size) { + eprintf ("sparse buffer problem, giving up\n"); + goto fail; + } + //} //advance cursor, reset section - sec_start = segreg + addr_tmp; + // sec_start = segreg + addr_tmp; next_addr = addr_tmp; sec_size = 0; } - for (i = 0; i < bc; i++) { - if (sscanf (str + 9+ (i*2), "%02x", &byte) !=1) { - eprintf ("unparsable data !\n"); - goto fail; - } - if (sec_size + i < sec_count) { - sec_tmp[sec_size + i] = (ut8) byte & 0xff; - } - cksum += byte; - } sec_size += bc; next_addr += bc; if (eol) { // checksum - if (sscanf(str+9+(i*2), "%02x", &byte) !=1) { + if (sscanf (str + 9 + (i * 2), "%02x", &byte) !=1) { eprintf("unparsable data !\n"); goto fail; } @@ -308,8 +310,8 @@ static bool ihex_parse(RBuffer *rbuf, char *str) { str = eol; break; case 1: // EOF. we don't validate checksum here - if (sec_size) { - if (r_buf_write_at(rbuf, sec_start, sec_tmp, sec_size) != sec_size) { + if (at && sec_size) { + if (r_buf_write_at (rbuf, at, sec_tmp, sec_size) != sec_size) { eprintf ("sparse buffer problem, giving up. ssiz=%X, sstart=%X\n", sec_size, sec_start); goto fail; } @@ -321,9 +323,9 @@ static bool ihex_parse(RBuffer *rbuf, char *str) { //both rec types are handled the same except : // new address = seg_reg <<4 for type 02; new address = lin_addr <<16 for type 04. //write current section - if (sec_size) { - if (r_buf_write_at(rbuf, sec_start, sec_tmp, sec_size) != sec_size) { - eprintf("sparse buffer problem, giving up\n"); + if (sec_size && at) { + if (r_buf_write_at (rbuf, at, sec_tmp, sec_size) != sec_size) { + eprintf ("sparse buffer problem, giving up\n"); goto fail; } } @@ -350,10 +352,10 @@ static bool ihex_parse(RBuffer *rbuf, char *str) { extL &= 0xff; cksum += extH + extL; - segreg = extH <<8 | extL; + segreg = (extH << 8) | extL; //segment rec(02) gives bits 4..19; linear rec(04) is bits 16..31 - segreg = segreg << ((type==2)? 4: 16); + segreg = segreg << ((type == 2)? 4: 16); next_addr = 0; sec_start = segreg; @@ -401,6 +403,7 @@ static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) { return NULL; } mal->rbuf = r_buf_new_sparse (io->Oxff); + // mal->rbuf = r_buf_new_empty (1024 * 1024 * 8); if (!mal->rbuf) { free (str); free (mal); diff --git a/test/db/io/ihex b/test/db/io/ihex index 1bc91dcac220e..dc838119bd835 100644 --- a/test/db/io/ihex +++ b/test/db/io/ihex @@ -10,3 +10,31 @@ goto 0x246e return 0 EOF RUN + +NAME=IHEX: simple test +FILE=ihex://bins/other/test.ihex +CMDS=< Date: Sun, 13 Feb 2022 23:40:57 +0100 Subject: [PATCH 007/390] New 'w+' command, to write a string and seek at the end ##shell --- libr/core/cmd_write.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/libr/core/cmd_write.c b/libr/core/cmd_write.c index 362cfae255c10..f34375966cd23 100644 --- a/libr/core/cmd_write.c +++ b/libr/core/cmd_write.c @@ -10,6 +10,7 @@ static const char *help_msg_w[] = { "Usage:","w[x] [str] [config, "cfg.wseek"); char *str = strdup (input); /* write string */ int len = r_str_unescape (str); + // handle charset logic here if (!r_core_write_at (core, core->offset, (const ut8 *)str, len)) { cmd_write_fail (core); } free (str); WSEEK (core, len); r_core_block_read (core); -} - -static int w_handler_old(void *data, const char *input) { - RCore *core = (RCore *)data; - w_handler_common (core, input); + core->num->value = len; return 0; } @@ -2135,6 +2133,7 @@ static int cmd_write(void *data, const char *input) { wA_handler_old (core, input + 1); break; case ' ': // "w" + case '+': // "w+" { size_t len = core->blocksize; const char *curcs = r_config_get (core->config, "cfg.charset"); @@ -2143,23 +2142,31 @@ static int cmd_write(void *data, const char *input) { r_str_trim_args (str); r_str_trim_tail (str); + ut64 addr = core->offset; if (R_STR_ISEMPTY (curcs)) { - w_handler_old (core, str + 1); + core->num->value = 0; + w_handler (core, str + 1); + addr += core->num->value; } else { if (len > 0) { size_t in_len = strlen (str + 1); int max = core->print->charset->encode_maxkeylen; int out_len = in_len * max; + int new_len = 0; ut8 *out = malloc (in_len * max); //suppose in len = out len TODO: change it if (out) { *out = 0; - r_charset_decode_str (core->print->charset, out, out_len, (const ut8*) str + 1, in_len); - w_handler_old (core, (const char *)out); + new_len = r_charset_decode_str (core->print->charset, out, out_len, (const ut8*) str + 1, in_len); + w_handler (core, (const char *)out); free (out); } + addr += new_len; } } free (str); + if (*input == '+') { + r_core_seek (core, addr, true); + } break; } case 'z': // "wz" From 46236dc4bf361c48c5fcb4b12903bcbf445835a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20=C3=80lvarez=20i=20Capilla?= Date: Sun, 13 Feb 2022 23:44:16 +0100 Subject: [PATCH 008/390] Add test for the w+ command --- test/db/cmd/cmd_w | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/db/cmd/cmd_w b/test/db/cmd/cmd_w index 823c6755c9c78..717198cdc0acd 100644 --- a/test/db/cmd/cmd_w +++ b/test/db/cmd/cmd_w @@ -430,3 +430,20 @@ EXPECT=< Date: Mon, 14 Feb 2022 00:03:50 +0100 Subject: [PATCH 009/390] Improve github's template for the PRs --- .github/PULL_REQUEST_TEMPLATE.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index c6280260228f6..3bdc383179d7e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,17 +1,14 @@ - -**Checklist** - -- [ ] Closing issues: #issue - [ ] Mark this if you consider it ready to merge - [ ] I've added tests (optional) -- [ ] I wrote some lines in the [radare2book](https://github.com/radareorg/radare2book) +- [ ] I wrote some lines in the [book](https://github.com/radareorg/radare2book) (optional) **Description** - + From dc7c60b1bb10f11e584c5716d3914bbd45924fdd Mon Sep 17 00:00:00 2001 From: wargio Date: Mon, 14 Feb 2022 00:57:27 +0100 Subject: [PATCH 010/390] Handle SH, MIPS and ARM in COFF binaries ##bin --- libr/bin/format/coff/coff.c | 10 +++++++++- libr/bin/p/bin_coff.c | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/libr/bin/format/coff/coff.c b/libr/bin/format/coff/coff.c index e911d1fcc82e6..4b3e094f5bd43 100644 --- a/libr/bin/format/coff/coff.c +++ b/libr/bin/format/coff/coff.c @@ -9,6 +9,9 @@ bool r_coff_supported_arch(const ut8 *buf) { ut16 arch = *(ut16*)buf; switch (arch) { + case COFF_FILE_MACHINE_MIPS16: + case COFF_FILE_MACHINE_MIPSFPU: + case COFF_FILE_MACHINE_MIPSFPU16: case COFF_FILE_MACHINE_AMD64: case COFF_FILE_MACHINE_I386: case COFF_FILE_MACHINE_H8300: @@ -16,8 +19,13 @@ bool r_coff_supported_arch(const ut8 *buf) { case COFF_FILE_MACHINE_R4000: case COFF_FILE_MACHINE_AMD29KBE: case COFF_FILE_MACHINE_AMD29KLE: + case COFF_FILE_MACHINE_SH3: + case COFF_FILE_MACHINE_SH3DSP: + case COFF_FILE_MACHINE_SH4: + case COFF_FILE_MACHINE_SH5: + case COFF_FILE_MACHINE_THUMB: + case COFF_FILE_MACHINE_ARM: case COFF_FILE_MACHINE_ARM64: - case COFF_FILE_MACHINE_ARM: case COFF_FILE_MACHINE_ARMNT: return true; default: diff --git a/libr/bin/p/bin_coff.c b/libr/bin/p/bin_coff.c index 448d4aec3944d..0bfcdb95753a3 100644 --- a/libr/bin/p/bin_coff.c +++ b/libr/bin/p/bin_coff.c @@ -549,6 +549,14 @@ static RBinInfo *info(RBinFile *bf) { } switch (obj->hdr.f_magic) { + case COFF_FILE_MACHINE_R4000: + case COFF_FILE_MACHINE_MIPS16: + case COFF_FILE_MACHINE_MIPSFPU: + case COFF_FILE_MACHINE_MIPSFPU16: + ret->machine = strdup ("mips"); + ret->arch = strdup ("mips"); + ret->bits = 32; + break; case COFF_FILE_MACHINE_I386: ret->machine = strdup ("i386"); ret->arch = strdup ("x86"); @@ -559,6 +567,11 @@ static RBinInfo *info(RBinFile *bf) { ret->arch = strdup ("arm"); ret->bits = 64; break; + case COFF_FILE_MACHINE_THUMB: + ret->machine = strdup ("arm"); + ret->arch = strdup ("arm"); + ret->bits = 16; + break; case COFF_FILE_MACHINE_ARM: ret->machine = strdup ("ARM"); ret->arch = strdup ("arm"); @@ -586,6 +599,14 @@ static RBinInfo *info(RBinFile *bf) { ret->arch = strdup ("arm"); ret->bits = 32; break; + case COFF_FILE_MACHINE_SH3: + case COFF_FILE_MACHINE_SH3DSP: + case COFF_FILE_MACHINE_SH4: + case COFF_FILE_MACHINE_SH5: + ret->machine = strdup ("sh"); + ret->arch = strdup ("sh"); + ret->bits = 32; + break; case COFF_FILE_TI_COFF: switch (obj->target_id) { case COFF_FILE_MACHINE_TMS320C54: From a2b0bfa4eb3209c93ff5a6c8f311c98aab98e2c8 Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Sun, 13 Feb 2022 19:55:52 +0100 Subject: [PATCH 011/390] Rework SOURCE_DATE_EPOCH to be portable --- meson.build | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 645378b975152..e61ca5bd23d3a 100644 --- a/meson.build +++ b/meson.build @@ -72,11 +72,12 @@ endif if host_machine.system() == 'windows' r2birth = run_command('cmd', '/c', 'echo %date%__%time%') else - source_date_epoch = run_command('sh', '-c', 'echo $SOURCE_DATE_EPOCH').stdout().strip() - if source_date_epoch == '' - source_date_epoch = run_command('date', '+%s').stdout().strip() - endif - r2birth = run_command('date', '-u', '-d', '@' + source_date_epoch, '+%Y-%m-%d__%H:%M:%S') + r2birth = run_command('sh', '-c', ''' + SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-`date +%s`}"; + FORMAT="+%Y-%m-%d__%H:%M:%S"; + date -u -d @"$SOURCE_DATE_EPOCH" "$FORMAT" 2>/dev/null || + date -u -r "$SOURCE_DATE_EPOCH" "$FORMAT" 2>/dev/null || + date -u "$FORMAT"''') endif if r2birth.returncode() != 0 r2birth = '' From ed76d94144720c8c9e29797647108cf1b28b1dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20=C3=80lvarez=20i=20Capilla?= Date: Mon, 14 Feb 2022 01:31:22 +0100 Subject: [PATCH 012/390] Fix more harmless asan oobreads in pdu and fc --- libr/core/cmd_flag.c | 6 +++--- libr/core/cmd_print.c | 13 +++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/libr/core/cmd_flag.c b/libr/core/cmd_flag.c index 32ccb3eb68473..e495250bc9e6c 100644 --- a/libr/core/cmd_flag.c +++ b/libr/core/cmd_flag.c @@ -1283,7 +1283,7 @@ static int cmd_flag(void *data, const char *input) { RFlagItem *fi; r_list_foreach (list, iter, fi) { if (fi->color) { - if (input[2] == '*') { + if (input[1] && input[2] == '*') { r_cons_printf ("fc %s=%s\n", fi->name, fi->color); } else { const char *pad = r_str_pad (' ', 10- strlen (fi->name)); @@ -1294,8 +1294,8 @@ static int cmd_flag(void *data, const char *input) { } else if (input[1] == '-') { RListIter *iter; RFlagItem *fi; - ut64 addr = (input[2] != '*' && input[2]) ? r_num_math (core->num, input + 2): core->offset; - const RList *list = (input[2]=='*')? + ut64 addr = (input[1] && input[2] != '*' && input[2]) ? r_num_math (core->num, input + 2): core->offset; + const RList *list = (input[1] && input[2]=='*')? r_flag_all_list (core->flags, false) : r_flag_get_list (core->flags, addr); r_list_foreach (list, iter, fi) { diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index 65e5ae3bc3270..143c71d992779 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -1108,7 +1108,7 @@ static int cmd_pdu(RCore *core, const char *input) { ut64 to; ut64 count; - if (input[1] == '?' || input[2] == '?' || !arg) { + if (input[1] == '?' || (input[1] && input[2] == '?') || !arg) { r_core_cmd_help_match (core, help_msg_pdu, "pdua", true); break; } @@ -1139,7 +1139,7 @@ static int cmd_pdu(RCore *core, const char *input) { } break; case 'c': // "pduc" - if (input[1] == '?' || input[2] == '?') { + if (input[1] == '?' || (input[1] && input[2] == '?')) { r_core_cmd_help_match (core, help_msg_pdu, "pduc", true); break; } @@ -1157,29 +1157,26 @@ static int cmd_pdu(RCore *core, const char *input) { input[1] == 'j', NULL, NULL); break;*/ case 'i': // "pdui" - if (input[1] == '?' || input[2] == '?' || !arg) { + if (input[1] == '?' || (input[1] && input[2] == '?') || !arg) { r_core_cmd_help_match (core, help_msg_pdu, "pdui", true); break; } - ret = r_core_print_disasm (core, addr, buf, len, 0, instruction, arg, false, input[1] == 'j', NULL, NULL); break; case 'o': // "pduo" - if (input[1] == '?' || input[2] == '?' || !arg) { + if (input[1] == '?' || (input[1] && input[2] == '?') || !arg) { r_core_cmd_help_match (core, help_msg_pdu, "pduo", true); break; } - ret = r_core_print_disasm (core, addr, buf, len, 0, opcode, arg, false, input[1] == 'j', NULL, NULL); break; case 's': // "pdus" - if (input[1] == '?' || input[2] == '?') { + if (input[1] == '?' || (input[1] && input[2] == '?')) { r_core_cmd_help_match (core, help_msg_pdu, "pdus", true); break; } - ret = r_core_print_disasm (core, addr, buf, len, 0, instruction, "syscall", false, input[1] == 'j', NULL, NULL); break; From dd25b01275305323f833aa3e859fe8d366ea36b2 Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 14 Feb 2022 01:55:27 +0100 Subject: [PATCH 013/390] Fix 'disable mouse' ansi code ##cons Co-authored-by: Segev Finer --- libr/cons/cons.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libr/cons/cons.c b/libr/cons/cons.c index a8fa3bdc89ae4..c48b4f3bdd2ca 100644 --- a/libr/cons/cons.c +++ b/libr/cons/cons.c @@ -562,8 +562,8 @@ R_API bool r_cons_enable_mouse(const bool enable) { #endif const char *click = enable ? "\x1b[?1000;1006;1015h" - : "\x1b[?1001r" - "\x1b[?1000l"; + : "\x1b[?1000;1006;1015l"; + // : "\x1b[?1001r\x1b[?1000l"; // : "\x1b[?1000;1006;1015l"; // const char *old = enable ? "\x1b[?1001s" "\x1b[?1000h" : "\x1b[?1001r" "\x1b[?1000l"; bool enabled = I->mouse; From 62d6d226ffe550f3929a6c850f32371c6dbfd30b Mon Sep 17 00:00:00 2001 From: Anton Kochkov Date: Mon, 14 Feb 2022 01:03:44 +0100 Subject: [PATCH 014/390] Fix cmn, teq and tst in arm32 assembler ##asm --- libr/asm/arch/arm/armass.c | 8 ++++---- test/db/asm/arm_32 | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libr/asm/arch/arm/armass.c b/libr/asm/arch/arm/armass.c index 68c77fa011217..dc794bc1250f7 100644 --- a/libr/asm/arch/arm/armass.c +++ b/libr/asm/arch/arm/armass.c @@ -131,9 +131,9 @@ static ArmOp ops[] = { { "cmp", 0x5001, TYPE_TST }, { "swp", 0xe1, TYPE_SWP }, - { "cmn", 0x0, TYPE_TST }, - { "teq", 0x0, TYPE_TST }, - { "tst", 0xe1, TYPE_TST }, + { "cmn", 0x7001, TYPE_TST }, + { "teq", 0x3001, TYPE_TST }, + { "tst", 0x1001, TYPE_TST }, {"lsr", 0x3000a0e1, TYPE_SHFT}, {"asr", 0x5000a0e1, TYPE_SHFT}, @@ -6415,7 +6415,7 @@ static int arm_assemble(ArmOpcode *ao, ut64 off, const char *str) { ao->o |= (y << 24); ao->o |= (z << 16); } else { - eprintf ("Parameter %d out0x3000a0e1 of range (0-255)\n", (int)b); + eprintf ("Parameter %d out of range (0-255)\n", (int)b); return 0; } } else { diff --git a/test/db/asm/arm_32 b/test/db/asm/arm_32 index 5fd02d4f9299e..7fff977ad72cc 100644 --- a/test/db/asm/arm_32 +++ b/test/db/asm/arm_32 @@ -20,7 +20,7 @@ aB "bxeq Lr" 1eff2f01 aB "bxne Lr" 1eff2f11 a "clzne r5, sl" 1a5f6f11 aB "cmpeq sl, r4" 40005a01 -a "cmpne r7, r6" 06005711 +ad "cmpne r7, r6" 06005711 a "eoreq r2, r2, 1" 01202202 a "eorne r0, r0, r3" 03002010 aB "eorne r0, r0, r3, lsr #24" 230c2010 @@ -275,3 +275,6 @@ a "ldr r0, [r0]" 000090e5 a "ldr r1, [r2]" 001092e5 a "str r0, [r0]" 000080e5 a "str r1, [r2]" 001082e5 +ad "tst r1, r2" 020011e1 +ad "cmn r1, r3" 030071e1 +ad "teq r3, r4" 040033e1 From 5a7ffe4c0a71794fbb0b945d52065c7c11d1eec2 Mon Sep 17 00:00:00 2001 From: Florian M Date: Mon, 14 Feb 2022 01:17:26 +0100 Subject: [PATCH 015/390] Add ELF reloc patching for R_386_32 and R_386_PC32 ##bin --- libr/bin/p/bin_elf.inc | 17 +++++++++++ test/db/formats/elf/reloc | 63 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/libr/bin/p/bin_elf.inc b/libr/bin/p/bin_elf.inc index 8f275f3e34837..2f8bd6b685de3 100644 --- a/libr/bin/p/bin_elf.inc +++ b/libr/bin/p/bin_elf.inc @@ -838,6 +838,23 @@ static void _patch_reloc(struct Elf_(r_bin_elf_obj_t) *bo, ut16 e_machine, RIOBi } break; } + case EM_386: + switch (rel->type) { + case R_386_32: + case R_386_PC32: + { + r_io_read_at (iob->io, rel->rva, buf, 4); + ut32 v = r_read_le32 (buf) + S + A; + if (rel->type == R_386_PC32) { + v -= P; + } + r_write_le32 (buf, v); + r_io_write_at (iob->io, rel->rva, buf, 4); + } + default: + break; + } + break; case EM_X86_64: { int word = 0; switch (rel->type) { diff --git a/test/db/formats/elf/reloc b/test/db/formats/elf/reloc index 88dac3be33043..46d6c1a7e89a5 100644 --- a/test/db/formats/elf/reloc +++ b/test/db/formats/elf/reloc @@ -99,4 +99,65 @@ EXPECT=< Date: Mon, 14 Feb 2022 16:39:36 +0100 Subject: [PATCH 016/390] Fix redefined macro warning in plan9 plugin --- libr/bin/p/bin_p9.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libr/bin/p/bin_p9.c b/libr/bin/p/bin_p9.c index 5c70a3e7f06cb..b486d00defdf3 100644 --- a/libr/bin/p/bin_p9.c +++ b/libr/bin/p/bin_p9.c @@ -1,4 +1,4 @@ -/* radare2 - LGPL - Copyright 2009-2021 - nibble, pancake, keegan */ +/* radare2 - LGPL - Copyright 2009-2022 - nibble, pancake, keegan */ #include #include @@ -6,7 +6,8 @@ #include #include "../format/p9/p9bin.h" -#define ALIGN(address, align) (((address) + (align - 1)) & ~(align - 1)) +#undef P9_ALIGN +#define P9_ALIGN(address, align) (((address) + (align - 1)) & ~(align - 1)) static bool check_buffer(RBinFile *bf, RBuffer *buf) { RSysArch arch; @@ -128,7 +129,7 @@ static RList *sections(RBinFile *bf) { } ptr->name = strdup ("text"); ptr->size = header->text; - ptr->vsize = ALIGN(header->text, align); + ptr->vsize = P9_ALIGN (header->text, align); ptr->paddr = phys; ptr->vaddr = baddr (bf); ptr->perm = R_PERM_RX; // r-x @@ -152,7 +153,7 @@ static RList *sections(RBinFile *bf) { } ptr->name = strdup ("data"); ptr->size = header->data; - ptr->vsize = ALIGN(header->data, align); + ptr->vsize = P9_ALIGN (header->data, align); ptr->paddr = phys; ptr->vaddr = baddr (bf) + vsize; ptr->perm = R_PERM_RW; @@ -167,7 +168,7 @@ static RList *sections(RBinFile *bf) { } ptr->name = strdup ("bss"); ptr->size = 0; - ptr->vsize = ALIGN (header->bss, align); + ptr->vsize = P9_ALIGN (header->bss, align); ptr->paddr = 0; ptr->vaddr = baddr (bf) + vsize; ptr->perm = R_PERM_RW; @@ -182,7 +183,7 @@ static RList *sections(RBinFile *bf) { } ptr->name = strdup ("syms"); ptr->size = header->syms; - ptr->vsize = ALIGN(header->syms, align); + ptr->vsize = P9_ALIGN (header->syms, align); ptr->paddr = phys; ptr->vaddr = baddr (bf) + vsize; ptr->perm = R_PERM_R; // r-- @@ -197,7 +198,7 @@ static RList *sections(RBinFile *bf) { } ptr->name = strdup ("spsz"); ptr->size = header->spsz; - ptr->vsize = ALIGN(header->spsz, align); + ptr->vsize = P9_ALIGN (header->spsz, align); ptr->paddr = phys; ptr->vaddr = baddr (bf) + vsize; ptr->perm = R_PERM_R; // r-- @@ -212,7 +213,7 @@ static RList *sections(RBinFile *bf) { } ptr->name = strdup ("pcsz"); ptr->size = header->pcsz; - ptr->vsize = ALIGN(header->pcsz, align); + ptr->vsize = P9_ALIGN (header->pcsz, align); ptr->paddr = phys; ptr->vaddr = baddr (bf) + vsize; ptr->perm = R_PERM_R; // r-- From aa849b682b656c5e8f26e1ca42fd8d8078d74b72 Mon Sep 17 00:00:00 2001 From: Angel Diaz Date: Mon, 14 Feb 2022 10:25:23 -0300 Subject: [PATCH 017/390] Fix io/r_ptrace types definitions for FreeBSD (radareorg#19687) --- libr/include/r_io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libr/include/r_io.h b/libr/include/r_io.h index 92a1c7ec5245a..504965e13663e 100644 --- a/libr/include/r_io.h +++ b/libr/include/r_io.h @@ -58,7 +58,7 @@ typedef void * r_ptrace_data_t; #elif __APPLE__ typedef int r_ptrace_request_t; typedef int r_ptrace_data_t; -#elif __OpenBSD__ +#elif __OpenBSD__ || __FreeBSD__ typedef int r_ptrace_request_t; typedef int r_ptrace_data_t; #define R_PTRACE_NODATA 0 From 91740c46d28f61d1314bc6d28bf6d0f5af104762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20=C3=80lvarez=20i=20Capilla?= Date: Tue, 15 Feb 2022 10:19:48 +0100 Subject: [PATCH 018/390] Fix oobread in pxj ##crash * Reproducer: db/cmd/cmd_print * Proper refactoring and cleanup+testing on the works --- libr/core/cmd_print.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index 143c71d992779..1ec787b14ecd5 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -6582,7 +6582,17 @@ static int cmd_print(void *data, const char *input) { r_cons_break_push (NULL, NULL); switch (input[1]) { case 'j': // "pxj" - r_print_jsondump (core->print, block, len, 8); + if (len < core->blocksize) { + r_print_jsondump (core->print, core->block, R_MIN (core->blocksize, len), 8); + } else { + ut8 *data = malloc (len + 1); + if (data) { + memset (data, core->io->Oxff, len + 1); + r_io_read_at (core->io, core->offset, data, len); + r_print_jsondump (core->print, data, len, 8); + free (data); + } + } break; case '/': // "px/" r_core_print_examine (core, input + 2); From e13fb7d1834583ccd6d06076139d684a75d39329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20=C3=80lvarez=20i=20Capilla?= Date: Tue, 15 Feb 2022 10:55:55 +0100 Subject: [PATCH 019/390] Support building with system-provided lz4 library ##build --- config-user.mk.acr | 2 ++ configure | 27 +++++++++++++++++++++++---- configure.acr | 14 +++++++++++++- libr/util/Makefile | 5 +++++ libr/util/meson.build | 11 ++++++++++- meson.build | 1 + shlr/lz4/meson.build | 21 +++++++++++++++++++++ shlr/meson.build | 24 ------------------------ 8 files changed, 75 insertions(+), 30 deletions(-) create mode 100644 shlr/lz4/meson.build diff --git a/config-user.mk.acr b/config-user.mk.acr index 1a8b06b7b2774..aa4b0a85dff7f 100644 --- a/config-user.mk.acr +++ b/config-user.mk.acr @@ -95,6 +95,8 @@ LIBMAGIC=@LIBMAGIC@ LIBZIP=@LIBZIP@ LIBXXHASH=@LIBXXHASH@ +USE_SYSLZ4=@USE_SYSLZ4@ + ifeq ($(HAVE_LIB_SSL),1) SSL_CFLAGS=@SSL_CFLAGS@ SSL_LDFLAGS=@SSL_LDFLAGS@ diff --git a/configure b/configure index 90ebb47a17018..569010593dc81 100755 --- a/configure +++ b/configure @@ -31,6 +31,7 @@ WITH_LIBR=0 USE_CS5=0 USE_CS4=0 WITH_CAPSTONE=0 +WITH_SYSLZ4=0 USE_ZIP=0 USE_XXHASH=0 WITH_GPL=1 @@ -195,6 +196,7 @@ Optional Features: --with-capstone5 build next branch of capstone5 (default) --with-capstone4 build v4 branch of capstone --with-syscapstone force to use system-wide capstone + --with-syslz4 force to use system's liblz4 --with-syszip force to use system's libzip and zlib --with-sysxxhash force to use system's xxhash --without-gpl do not build GPL code (grub, cxx, ... ) @@ -278,8 +280,8 @@ echo "VERSION: 5.6.1" echo "LANGS: c" echo "REQUIRED: libdl" echo "OPTIONAL: libmagic libz libzip libxxhash libssl liblibuv>=1.0.0" -echo "PKG-CONFIG: capstone openssl libuv" -echo "FLAGS: --disable-debugger --with-sysmagic --disable-threads --disable-loadlibs --without-dylink --without-fork --without-ptrace-wrap --without-gperf --without-capstone --with-libr --with-capstone5 --with-capstone4 --with-syscapstone --with-syszip --with-sysxxhash --without-gpl --with-openssl --without-libuv --with-rpath --with-compiler=gcc --with-ostype=auto --with-libversion=xxx --without-jemalloc --with-checks-level=2" +echo "PKG-CONFIG: capstone liblz4 openssl libuv" +echo "FLAGS: --disable-debugger --with-sysmagic --disable-threads --disable-loadlibs --without-dylink --without-fork --without-ptrace-wrap --without-gperf --without-capstone --with-libr --with-capstone5 --with-capstone4 --with-syscapstone --with-syslz4 --with-syszip --with-sysxxhash --without-gpl --with-openssl --without-libuv --with-rpath --with-compiler=gcc --with-ostype=auto --with-libversion=xxx --without-jemalloc --with-checks-level=2" exit 0 ;; --cache-file) @@ -342,6 +344,7 @@ echo "FLAGS: --disable-debugger --with-sysmagic --disable-threads --disable- "--with-capstone5") USE_CS5="1"; ;; "--with-capstone4") USE_CS4="1"; ;; "--with-syscapstone") WITH_CAPSTONE="1"; ;; +"--with-syslz4") WITH_SYSLZ4="1"; ;; "--with-syszip") USE_ZIP="1"; ;; "--with-sysxxhash") USE_XXHASH="1"; ;; "--without-gpl") WITH_GPL="0"; ;; @@ -370,7 +373,7 @@ parse_options "$1" shift done -ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR ETCDIR SYSCONFDIR DATADIR DOCDIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_NUMBER PKGNAME VPATH CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C DEBUGGER HAVE_LIB_DL DL_LIBS PKGCONFIG HAVE_PATCH PATCH HAVE_AR AR HAVE_GIT GIT HAVE_GPERF GPERF HAVE_LIB_MAGIC USE_MAGIC USE_LIB_MAGIC LIBMAGIC WANT_THREADS LOADLIBS WANT_DYLINK HAVE_FORK WANT_PTRACE_WRAP WANT_GPERF WANT_CAPSTONE WITH_LIBR USE_CS5 USE_CS4 WITH_CAPSTONE CAPSTONE_CFLAGS CAPSTONE_LDFLAGS HAVE_PKGCFG_CAPSTONE USE_CAPSTONE HAVE_LIB_Z HAVE_LIB_ZIP USE_ZIP USE_LIB_ZIP LIBZIP HAVE_LIB_XXHASH USE_XXHASH USE_LIB_XXHASH LIBXXHASH WITH_GPL HAVE_DECL_ADDR_NO_RANDOMIZE HAVE_DECL___GLIBC__ HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET HAVE_CLOCK_NANOSLEEP HAVE_SIGACTION HAVE_CLOCK_GETTIME CLOCK_LDFLAGS SUPPORT_GNU99 HAVE_LIB_GMP HAVE_LIB_SSL SSL_CFLAGS SSL_LDFLAGS HAVE_PKGCFG_OPENSSL HAVE_OPENSSL WANT_OPENSSL HAVE_LIBUV_VERSION_1_0_0 LIBUV_CFLAGS LIBUV_LDFLAGS HAVE_PKGCFG_LIBUV HAVE_LIBUV WANT_LIBUV USE_RPATH USERCC USEROSTYPE LIBVERSION HAVE_JEMALLOC HAVE_PTRACE USE_PTRACE_WRAP R_CHECKS_LEVEL" +ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR ETCDIR SYSCONFDIR DATADIR DOCDIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_NUMBER PKGNAME VPATH CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C DEBUGGER HAVE_LIB_DL DL_LIBS PKGCONFIG HAVE_PATCH PATCH HAVE_AR AR HAVE_GIT GIT HAVE_GPERF GPERF HAVE_LIB_MAGIC USE_MAGIC USE_LIB_MAGIC LIBMAGIC WANT_THREADS LOADLIBS WANT_DYLINK HAVE_FORK WANT_PTRACE_WRAP WANT_GPERF WANT_CAPSTONE WITH_LIBR USE_CS5 USE_CS4 WITH_CAPSTONE CAPSTONE_CFLAGS CAPSTONE_LDFLAGS HAVE_PKGCFG_CAPSTONE USE_CAPSTONE LZ4_CFLAGS LZ4_LDFLAGS HAVE_PKGCFG_LIBLZ4 WITH_SYSLZ4 USE_LIB_LZ4 HAVE_LIB_Z HAVE_LIB_ZIP USE_ZIP USE_LIB_ZIP LIBZIP HAVE_LIB_XXHASH USE_XXHASH USE_LIB_XXHASH LIBXXHASH WITH_GPL HAVE_DECL_ADDR_NO_RANDOMIZE HAVE_DECL___GLIBC__ HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET HAVE_CLOCK_NANOSLEEP HAVE_SIGACTION HAVE_CLOCK_GETTIME CLOCK_LDFLAGS SUPPORT_GNU99 HAVE_LIB_GMP HAVE_LIB_SSL SSL_CFLAGS SSL_LDFLAGS HAVE_PKGCFG_OPENSSL HAVE_OPENSSL WANT_OPENSSL HAVE_LIBUV_VERSION_1_0_0 LIBUV_CFLAGS LIBUV_LDFLAGS HAVE_PKGCFG_LIBUV HAVE_LIBUV WANT_LIBUV USE_RPATH USERCC USEROSTYPE LIBVERSION HAVE_JEMALLOC HAVE_PTRACE USE_PTRACE_WRAP R_CHECKS_LEVEL" create_environ @@ -601,6 +604,22 @@ if [ 11 = "$WITH_CAPSTONE$HAVE_PKGCFG_CAPSTONE" ]; then USE_CAPSTONE="1" else USE_CAPSTONE="0"; fi +if [ -z "${PKGCONFIG}" ]; then pkg-config --version >/dev/null 2>&1 ; if [ 0 = 0 ]; then PKGCONFIG=pkg-config ; else PKGCONFIG=pkgconf ; fi; fi +printf 'checking pkg-config flags for liblz4... ' +tmp=`${PKGCONFIG} --cflags liblz4 2>/dev/null` +if [ $? != 0 ]; then echo no ; HAVE_PKGCFG_LIBLZ4=0; +LZ4_CFLAGS='';LZ4_LDFLAGS=''; +else +LZ4_CFLAGS=$tmp; +tmp=`${PKGCONFIG} --libs liblz4 2>/dev/null` +if [ $? = 0 ]; then +echo yes; HAVE_PKGCFG_LIBLZ4=1; +LZ4_LDFLAGS=$tmp; fi; fi +if [ 11 = "$WITH_SYSLZ4$LZ4_CFLAGS" ]; then + +USE_LIB_LZ4="1" +else +USE_LIB_LZ4="0"; fi check_library HAVE_LIB_Z z 0 check_library HAVE_LIB_ZIP zip 0 if [ 11 = "$HAVE_LIB_Z$USE_ZIP" ]; then @@ -866,7 +885,7 @@ do_remove if [ "$QUIET" = 0 ]; then echo echo "Final report:" -for A in R_CHECKS_LEVEL PREFIX HAVE_LIB_GMP HAVE_OPENSSL HAVE_LIBUV USE_CAPSTONE HAVE_PTRACE USE_PTRACE_WRAP HAVE_FORK VERSION USE_LIB_ZIP USE_LIB_MAGIC USE_LIB_XXHASH DEBUGGER CC USERCC HAVE_ARC4RANDOM_UNIFORM PKGCONFIG HAVE_GPERF HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET WANT_DYLINK USEROSTYPE LIBVERSION BUILD HOST TARGET CFLAGS LDFLAGS ; do +for A in R_CHECKS_LEVEL PREFIX HAVE_LIB_GMP HAVE_OPENSSL HAVE_LIBUV USE_CAPSTONE HAVE_PTRACE USE_PTRACE_WRAP HAVE_FORK USE_LIB_LZ4 VERSION USE_LIB_ZIP USE_LIB_MAGIC USE_LIB_XXHASH DEBUGGER CC USERCC HAVE_ARC4RANDOM_UNIFORM PKGCONFIG HAVE_GPERF HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET WANT_DYLINK USEROSTYPE LIBVERSION BUILD HOST TARGET CFLAGS LDFLAGS ; do eval VAL="\$${A}" [ -z "${VAL}" ] && VAL="(null)" echo " - ${A} = ${VAL}" diff --git a/configure.acr b/configure.acr index 2b5e0e3779faf..53eb58b8259d2 100644 --- a/configure.acr +++ b/configure.acr @@ -42,6 +42,7 @@ IFNOT WANT_GPERF { ARG_WITH WITH_LIBR libr build libr.a and libr.dylib ; +(( CAPSTONE )) ARG_WITH USE_CS5 capstone5 build next branch of capstone5 (default) ; ARG_WITH USE_CS4 capstone4 build v4 branch of capstone ; @@ -55,6 +56,17 @@ IFAND WITH_CAPSTONE HAVE_PKGCFG_CAPSTONE { USE_CAPSTONE = 0 ; } +(( LZ4 )) +PKGCFG LZ4_CFLAGS LZ4_LDFLAGS liblz4 +ARG_WITH WITH_SYSLZ4 syslz4 force to use system's liblz4 ; +IFAND WITH_SYSLZ4 LZ4_CFLAGS { + USE_SYSLZ4 = 1 ; +}{ + USE_SYSLZ4 = 0 ; + +} + +(( ZIP )) CHKLIB z CHKLIB zip ARG_WITH USE_ZIP syszip force to use system's libzip and zlib ; @@ -251,7 +263,7 @@ ARG_WITH R_CHECKS_LEVEL=2 checks-level value between 0 and 3 to enable different REPORT R_CHECKS_LEVEL PREFIX HAVE_LIB_GMP HAVE_OPENSSL HAVE_LIBUV USE_CAPSTONE HAVE_PTRACE USE_PTRACE_WRAP HAVE_FORK - VERSION USE_LIB_ZIP USE_LIB_MAGIC USE_LIB_XXHASH DEBUGGER + USE_LIB_LZ4 VERSION USE_LIB_ZIP USE_LIB_MAGIC USE_LIB_XXHASH DEBUGGER CC USERCC HAVE_ARC4RANDOM_UNIFORM PKGCONFIG HAVE_GPERF HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET WANT_DYLINK USEROSTYPE LIBVERSION BUILD HOST TARGET CFLAGS LDFLAGS ; diff --git a/libr/util/Makefile b/libr/util/Makefile index 976338640b619..5a76fef1472fc 100644 --- a/libr/util/Makefile +++ b/libr/util/Makefile @@ -23,7 +23,12 @@ OBJS+=d/ebcdic37.o OBJS+=d/iso8859_1.o endif +ifeq ($(USE_SYSLZ4),1) +CFLAGS+=@LZ4_CFLAGS@ +PCLIBS+=@LZ4_LDFLAGS@ +else OBJS+=$(SHLR)/lz4/lz4.o +endif ifeq (${HAVE_LIB_GMP},1) OBJS+=big_gmp.o diff --git a/libr/util/meson.build b/libr/util/meson.build index c369f0cb402c7..f2613e5c03b0f 100644 --- a/libr/util/meson.build +++ b/libr/util/meson.build @@ -1,7 +1,6 @@ subdir('d') r_util_sources = [ - '../../shlr/lz4/lz4.c', 'ascii_table.c', 'assert.c', 'w32.c', @@ -97,6 +96,16 @@ if get_option('sdb_cgen') r_util_sources += r_util_d_sources endif +if lz4_dep.found() and get_option('use_sys_lz4') + # r_util_deps += lz4_dep + r_util_deps += declare_dependency( + link_with: libr2lz4, + include_directories: lz4_inc + ) +else + r_util_sources += '../../shlr/lz4/lz4.c' +endif + r_util_deps = [ldl, mth, spp_dep, pth, utl, sdb_dep, zlib_dep, platform_deps] if host_machine.system().startswith('freebsd') or host_machine.system().startswith('netbsd') or host_machine.system().startswith('haiku') # backtrace_symbols_fd requires -lexecinfo diff --git a/meson.build b/meson.build index e61ca5bd23d3a..29a7e725678bc 100644 --- a/meson.build +++ b/meson.build @@ -567,6 +567,7 @@ if get_option('local') and get_option('default_library') == 'shared' rpath_lib = '$ORIGIN' endif +subdir('shlr/lz4') subdir('libr/util') subdir('libr/socket') subdir('libr/hash') diff --git a/shlr/lz4/meson.build b/shlr/lz4/meson.build new file mode 100644 index 0000000000000..adac4937e1fcf --- /dev/null +++ b/shlr/lz4/meson.build @@ -0,0 +1,21 @@ +lz4_dep = dependency('liblz4', required: false) +if not lz4_dep.found() or not get_option('use_sys_lz4') + message('Using bundled lz4') + lz4_files = [ + 'lz4.c', + ] + + lz4_inc = [platform_inc, include_directories('.')] + + libr2lz4 = static_library('r2lz4', lz4_files, + include_directories: lz4_inc, + implicit_include_directories: false + ) + + lz4_dep = declare_dependency( + link_with: libr2lz4, + include_directories: lz4_inc + ) +else + message('Using system-provided lz4 library') +endif diff --git a/shlr/meson.build b/shlr/meson.build index 47328d177fd92..fe61ead1e02f4 100644 --- a/shlr/meson.build +++ b/shlr/meson.build @@ -273,30 +273,6 @@ qnx_dep = declare_dependency( include_directories: qnx_inc ) -# handle lz4 dependency (unused?) -lz4_dep = dependency('liblz4', required: false) -if not lz4_dep.found() or not get_option('use_sys_lz4') - message('Use bundled lz4') - lz4_files = [ - 'lz4/lz4.c', - ] - - lz4_inc = [platform_inc, include_directories('lz4')] - - libr2lz4 = static_library('r2lz4', lz4_files, - include_directories: lz4_inc, - implicit_include_directories: false - ) - - lz4_dep = declare_dependency( - link_with: libr2lz4, - include_directories: lz4_inc - ) -else - message('Use system-provided lz4 library') -endif - - # handle grub dependency grub_files = [ From 46a69a5014b1570af56f54eb1a12343d9969e1a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20=C3=80lvarez=20i=20Capilla?= Date: Tue, 15 Feb 2022 11:42:41 +0100 Subject: [PATCH 020/390] Fix all the latest covs which spotted new findings --- libr/anal/p/anal_avr.c | 2 +- libr/asm/arch/arm/armass.c | 30 +++++++++++------------ libr/asm/arch/cr16/cr16_disas.c | 42 +++++++++++++-------------------- libr/asm/arch/cr16/cr16_disas.h | 7 +++--- libr/bin/p/bin_psxexe.c | 4 ++-- libr/cons/dietline.c | 13 +++++----- libr/cons/pal.c | 3 --- libr/core/cmd_anal.c | 4 ++-- libr/core/p/core_java.c | 2 +- libr/io/p/io_ihex.c | 2 +- libr/reg/rvalue.c | 2 +- libr/util/unum.c | 2 +- shlr/grub/fs/fat.c | 2 +- shlr/lz4/lz4.c | 2 +- shlr/sdb/src/query.c | 4 ++-- 15 files changed, 54 insertions(+), 67 deletions(-) diff --git a/libr/anal/p/anal_avr.c b/libr/anal/p/anal_avr.c index a5d9241be72ed..de4c711162a88 100644 --- a/libr/anal/p/anal_avr.c +++ b/libr/anal/p/anal_avr.c @@ -1713,7 +1713,7 @@ static int avr_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len, ut64 offset = 0; r_anal_esil_reg_write (anal->esil, "_prog", offset); - offset += (1 << cpu->pc); + offset += (1ULL << cpu->pc); r_anal_esil_reg_write (anal->esil, "_io", offset); offset += const_get_value (const_by_name (cpu, CPU_CONST_PARAM, "sram_start")); diff --git a/libr/asm/arch/arm/armass.c b/libr/asm/arch/arm/armass.c index dc794bc1250f7..788e9a88aadca 100644 --- a/libr/asm/arch/arm/armass.c +++ b/libr/asm/arch/arm/armass.c @@ -1011,72 +1011,72 @@ static ut64 thumb_selector(char *args[]) { break; } if (getreg (args[i]) != -1) { - res |= 1 << (i*4); + res |= 1ULL << (i * 4); continue; } err = false; getnum (args[i]); if (!err) { - res |= 2 << (i*4); + res |= 2ULL << (i * 4); continue; } err = false; thumb_getshift (args[i]); if (!err) { - res |= 3 << (i*4); + res |= 3ULL << (i * 4); continue; } if (getcoproc (args[i]) != -1) { - res |= 4 << (i*4); + res |= 4ULL << (i * 4); continue; } if (getcoprocreg (args[i]) != -1) { - res |= 5 << (i*4); + res |= 5ULL << (i * 4); continue; } if (getregmemstart (args[i]) != -1) { - res |= 6 << (i*4); + res |= 6ULL << (i * 4); continue; } if (getregmemstartend (args[i]) != -1) { - res |= 7 << (i*4); + res |= 7ULL << (i * 4); continue; } err = false; getnummemend(args[i]); if (!err) { - res |= 8 << (i*4); + res |= 8ULL << (i * 4); continue; } err = false; getnummemendbang(args[i]); if (!err) { - res |= 9 << (i*4); + res |= 9ULL << (i * 4); continue; } if (getregmembang (args[i]) != -1) { - res |= 0xa << (i*4); + res |= 10ULL << (i * 4); continue; } if (getreglist (args[i]) != -1) { - res |= 0xb << (i*4); + res |= 11ULL << (i * 4); continue; } if (getregmemend (args[i]) != -1) { - res |= 0xc << (i*4); + res |= 12ULL << (i * 4); continue; } if (getshiftmemend (args[i]) != -1) { - res |= 0xd << (i*4); + res |= 13ULL << (i * 4); continue; } err = false; getnumbang(args[i]); if (!err) { - res |= 0xe << (i*4); + res |= 14ULL << (i * 4); continue; } - res |= 0xf << (i*4); + res |= 15ULL << (i * 4); } err = false; return res; diff --git a/libr/asm/arch/cr16/cr16_disas.c b/libr/asm/arch/cr16/cr16_disas.c index 6119a297225fd..90dd57e213304 100644 --- a/libr/asm/arch/cr16/cr16_disas.c +++ b/libr/asm/arch/cr16/cr16_disas.c @@ -1,6 +1,6 @@ -#include -#include +/* radare - LGPL - Copyright 2014-2022 - fedor.sakharov */ +#include #include "cr16_disas.h" #define GET_BIT(x, n) ((((x)) >> ((n))) & 1) @@ -63,6 +63,7 @@ static const char *cr16_conds[] = { [CR16_COND_FS] = "fs", [CR16_COND_FC] = "fc", [CR16_COND_LT] = "lt", + [CR16_COND_UC] = "uc", }; static const char *ld_sw[] = { @@ -110,8 +111,7 @@ static inline ut8 cr16_get_short_imm(const ut16 instr) return instr & 0x1F; } -static inline ut8 cr16_get_dstreg(const ut16 instr) -{ +static inline ut8 cr16_get_dstreg(const ut16 instr) { return (instr >> 5) & 0xF; } @@ -820,7 +820,7 @@ static int cr16_decode_bcond_br(const ut8 *instr, struct cr16_cmd *cmd, int len) } else { cmd->reladdr = disp32; } - snprintf(cmd->operands, CR16_INSTR_MAXLEN - 1, "0x%08x", disp32); + snprintf (cmd->operands, sizeof (cmd->operands) - 1, "0x%08x", disp32); } else { disp = (c & 0x1F) | ((c >> 4) & 0x1E0); @@ -830,14 +830,13 @@ static int cr16_decode_bcond_br(const ut8 *instr, struct cr16_cmd *cmd, int len) } else { cmd->reladdr = disp; } - - snprintf(cmd->operands, CR16_INSTR_MAXLEN - 1, "0x%04x", disp); + snprintf (cmd->operands, sizeof (cmd->operands) - 1, "0x%04x", disp); } } cmd->type = CR16_TYPE_JUMP; } else { - snprintf(cmd->instr, CR16_INSTR_MAXLEN - 1, "b%s", - cr16_conds[cr16_get_cond(c)]); + snprintf (cmd->instr, CR16_INSTR_MAXLEN - 1, "b%s", + cr16_conds[cr16_get_cond (c)]); if (c & 0x1) { return -1; } @@ -1128,32 +1127,23 @@ int cr16_decode_muls(const ut8 *instr, struct cr16_cmd *cmd, int len) return ret; } -int cr16_decode_scond(const ut8 *instr, struct cr16_cmd *cmd, int len) -{ - int ret = 2; - ut16 c; - +static int cr16_decode_scond(const ut8 *instr, struct cr16_cmd *cmd, int len) { if (len < 2) { return -1; } - c = r_read_le16 (instr); - + ut16 c = r_read_le16 (instr); if (c & 1) { return -1; } - - snprintf(cmd->instr, CR16_INSTR_MAXLEN - 1, "s%s", - cr16_conds[cr16_get_dstreg(c)]); - snprintf(cmd->operands, CR16_INSTR_MAXLEN - 1, "%s", - cr16_regs_names[cr16_get_srcreg(c)]); - + snprintf (cmd->instr, sizeof (cmd->instr) - 1, "s%s", + cr16_conds[cr16_get_dstreg (c)]); + snprintf(cmd->operands, sizeof (cmd->operands) - 1, "%s", + cr16_regs_names[cr16_get_srcreg (c)]); cmd->type = CR16_TYPE_SCOND; - - return ret; + return 2; } -int cr16_decode_biti(const ut8 *instr, struct cr16_cmd *cmd, int len) -{ +static int cr16_decode_biti(const ut8 *instr, struct cr16_cmd *cmd, int len) { int ret = 2; ut32 abs18; ut16 c, disp16; diff --git a/libr/asm/arch/cr16/cr16_disas.h b/libr/asm/arch/cr16/cr16_disas.h index 1a72a3eac39af..b829aa761e48b 100644 --- a/libr/asm/arch/cr16/cr16_disas.h +++ b/libr/asm/arch/cr16/cr16_disas.h @@ -131,18 +131,19 @@ enum cr16_dedic_regs { enum cr16_conds { CR16_COND_EQ = 0x0, CR16_COND_NE, + CR16_COND_GE, CR16_COND_CS, CR16_COND_CC, CR16_COND_HI, CR16_COND_LS, + CR16_COND_LO, + CR16_COND_HS, CR16_COND_GT, CR16_COND_LE, CR16_COND_FS, CR16_COND_FC, - CR16_COND_LO, - CR16_COND_HS, CR16_COND_LT, - CR16_COND_GE, + CR16_COND_UC, }; #endif /* CR16_DISASM_H */ diff --git a/libr/bin/p/bin_psxexe.c b/libr/bin/p/bin_psxexe.c index 47f9d42de3bb8..56e90384a863b 100644 --- a/libr/bin/p/bin_psxexe.c +++ b/libr/bin/p/bin_psxexe.c @@ -21,7 +21,7 @@ static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *b, ut64 loadaddr, static RBinInfo* info(RBinFile* bf) { RBinInfo* ret = NULL; - psxexe_header psxheader; + psxexe_header psxheader = {0}; if (r_buf_read_at (bf->buf, 0, (ut8*)&psxheader, sizeof(psxexe_header)) < sizeof(psxexe_header)) { eprintf ("Truncated Header\n"); @@ -45,7 +45,7 @@ static RBinInfo* info(RBinFile* bf) { static RList* sections(RBinFile* bf) { RList* ret = NULL; RBinSection* sect = NULL; - psxexe_header psxheader; + psxexe_header psxheader = {0}; ut64 sz = 0; if (!(ret = r_list_new ())) { diff --git a/libr/cons/dietline.c b/libr/cons/dietline.c index 141d404d8c3b1..e3757e5e56375 100644 --- a/libr/cons/dietline.c +++ b/libr/cons/dietline.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2007-2021 - pancake */ +/* radare - LGPL - Copyright 2007-2022 - pancake */ /* dietline is a lightweight and portable library similar to GNU readline */ #include @@ -20,17 +20,16 @@ static int r_line_readchar_win(ut8 *s, int slen); #define USE_UTF8 1 #endif -static char *r_line_nullstr = ""; static const char word_break_characters[] = "\t\n ~`!@#$%^&*()-_=+[]{}\\|;:\"'<>,./"; +// TODO: remove global variables +static R_TH_LOCAL bool enable_yank_pop = false; typedef enum { MINOR_BREAK, MAJOR_BREAK } BreakMode; -bool enable_yank_pop = false; - static inline bool is_word_break_char(char ch, bool mode) { int i; if (mode == MAJOR_BREAK) { @@ -1377,7 +1376,7 @@ R_API const char *r_line_readline_cb(RLineReadCallback cb, void *user) { if (!fgets (I.buffer.data, R_LINE_BUFSIZE, stdin)) { return NULL; } - return (*I.buffer.data)? I.buffer.data: r_line_nullstr; + return (*I.buffer.data)? I.buffer.data: ""; } memset (&buf, 0, sizeof buf); @@ -2067,7 +2066,7 @@ R_API const char *r_line_readline_cb(RLineReadCallback cb, void *user) { if (!memcmp (I.buffer.data, "!history", 8)) { // if (I.buffer.data[0]=='!' && I.buffer.data[1]=='\0') { r_line_hist_list (); - return r_line_nullstr; + return ""; } - return I.buffer.data[0] != '\0'? I.buffer.data: r_line_nullstr; + return I.buffer.data[0] != '\0'? I.buffer.data: ""; } diff --git a/libr/cons/pal.c b/libr/cons/pal.c index ff96403ca7536..ed757afe8e602 100644 --- a/libr/cons/pal.c +++ b/libr/cons/pal.c @@ -295,9 +295,6 @@ R_API char *r_cons_pal_parse(const char *str, R_NULLABLE RColor *outcol) { rcolor.id16 = -1; char *attr = NULL; char out[128]; - if (!str) { - return NULL; - } char *fgcolor = strdup (str); if (!fgcolor) { return NULL; diff --git a/libr/core/cmd_anal.c b/libr/core/cmd_anal.c index 95fe13423c1f9..3ef46e8752cfe 100644 --- a/libr/core/cmd_anal.c +++ b/libr/core/cmd_anal.c @@ -8664,7 +8664,7 @@ static bool cmd_anal_refs(RCore *core, const char *input) { char str[512]; int has_color = core->print->flags & R_PRINT_FLAGS_COLOR; r_list_foreach (list, iter, ref) { - ut8 buf[16]; + ut8 buf[16] = {0}; char *desc; char *desc_to_free = NULL; RFlagItem *flag = r_flag_get_at (core->flags, ref->addr, false); @@ -8690,7 +8690,7 @@ static bool cmd_anal_refs(RCore *core, const char *input) { if (ref->type == R_ANAL_REF_TYPE_CALL) { RAnalOp aop; - r_anal_op (core->anal, &aop, ref->addr, buf, sizeof(buf), R_ANAL_OP_MASK_BASIC); + r_anal_op (core->anal, &aop, ref->addr, buf, sizeof (buf), R_ANAL_OP_MASK_BASIC); if (aop.type == R_ANAL_OP_TYPE_UCALL) { cmd_anal_ucall_ref (core, ref->addr); } diff --git a/libr/core/p/core_java.c b/libr/core/p/core_java.c index 044f27f92e3bd..84e2ba48145b9 100644 --- a/libr/core/p/core_java.c +++ b/libr/core/p/core_java.c @@ -582,7 +582,7 @@ static int r_cmd_java_get_cp_bytes_and_write(RCore *core, RBinJavaObj *obj, ut16 bin_buffer = n_file_sz > 0? malloc (n_file_sz): NULL; if (bin_buffer) { memset (bin_buffer, 0, n_file_sz); - res = n_file_sz == r_io_read_at (core->io, obj->loadaddr, bin_buffer, n_file_sz)? true: false; + res = (n_file_sz == r_io_read_at (core->io, obj->loadaddr, bin_buffer, n_file_sz))? true: false; if (res == true) { res = r_cmd_java_reload_bin_from_buf ( core, obj, bin_buffer, n_file_sz); diff --git a/libr/io/p/io_ihex.c b/libr/io/p/io_ihex.c index 38a5d78b08417..ffe885424cd71 100644 --- a/libr/io/p/io_ihex.c +++ b/libr/io/p/io_ihex.c @@ -244,7 +244,7 @@ static bool ihex_parse(RBuffer *rbuf, char *str) { bc &= 0xff; addr_tmp &= 0xffff; type &= 0xff; - ut64 at = (!sec_start && sec_start == addr_tmp)? addr_tmp? addr_tmp:sec_start: sec_start + addr_tmp; + ut64 at = (!sec_start && sec_start == addr_tmp)? addr_tmp? addr_tmp: sec_start: sec_start + addr_tmp; switch (type) { case 0: // DATA diff --git a/libr/reg/rvalue.c b/libr/reg/rvalue.c index 9e51cea5c6710..877cb7b893e57 100644 --- a/libr/reg/rvalue.c +++ b/libr/reg/rvalue.c @@ -143,7 +143,7 @@ R_API ut64 r_reg_get_value_by_role(RReg *reg, RRegisterId role) { R_API bool r_reg_set_value(RReg *reg, RRegItem *item, ut64 value) { r_return_val_if_fail (reg && item, false); - ut8 bytes[12]; + ut8 bytes[12] = {0}; ut8 *src = bytes; if (r_reg_is_readonly (reg, item)) { diff --git a/libr/util/unum.c b/libr/util/unum.c index 666fd22d1ef88..a6d6a31589e61 100644 --- a/libr/util/unum.c +++ b/libr/util/unum.c @@ -161,7 +161,7 @@ static ut64 r_num_from_binary(const char *str) { ut64 ret = 0; for (j = 0, i = strlen (str) - 1; i > 0; i--, j++) { if (str[i] == '1') { - ret |= (1 << j); + ret |= (ut64) (1ULL << j); } else if (str[i] != '0') { break; } diff --git a/shlr/grub/fs/fat.c b/shlr/grub/fs/fat.c index 3c5f043b4baa9..50c68937a27ac 100644 --- a/shlr/grub/fs/fat.c +++ b/shlr/grub/fs/fat.c @@ -378,7 +378,7 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data, + data->logical_sector_bits + GRUB_DISK_SECTOR_BITS); logical_cluster = offset >> logical_cluster_bits; - offset &= (1 << logical_cluster_bits) - 1; + offset &= (1ULL << logical_cluster_bits) - 1; if (logical_cluster < data->cur_cluster_num) { diff --git a/shlr/lz4/lz4.c b/shlr/lz4/lz4.c index a2272cfb4a5bb..a62677bf4c840 100644 --- a/shlr/lz4/lz4.c +++ b/shlr/lz4/lz4.c @@ -1696,7 +1696,7 @@ int LZ4_saveDict (LZ4_stream_t* LZ4_dict, char* safeBuffer, int dictSize) if ((U32)dictSize > 64 KB) { dictSize = 64 KB; } /* useless to define a dictionary > 64 KB */ if ((U32)dictSize > dict->dictSize) { dictSize = (int)dict->dictSize; } - if (safeBuffer == NULL) assert(dictSize == 0); + if (safeBuffer == NULL) return 0; if (dictSize > 0) { const BYTE* const previousDictEnd = dict->dictionary + dict->dictSize; assert(dict->dictionary); diff --git a/shlr/sdb/src/query.c b/shlr/sdb/src/query.c index 393d284f3bb98..afd9eba08e2a3 100644 --- a/shlr/sdb/src/query.c +++ b/shlr/sdb/src/query.c @@ -1,4 +1,4 @@ -/* sdb - MIT - Copyright 2011-2021 - pancake */ +/* sdb - MIT - Copyright 2011-2022 - pancake */ #include #include @@ -163,7 +163,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { bool bufset = false; int i, d, ok, w, alength, is_ref = 0, encode = 0; const char *p, *q, *val = NULL; - char *eq, *tmp, *json, *next, *quot, *slash, *cmd; + char *eq, *tmp, *json, *next, *quot, *slash, *cmd = NULL; char *newcmd = NULL, *original_cmd = NULL; char *res = NULL; Sdb *s = r; From a88843e9896ecb23076dd57052c2704a87c91333 Mon Sep 17 00:00:00 2001 From: pancake Date: Tue, 15 Feb 2022 12:35:34 +0100 Subject: [PATCH 021/390] Early break when parsing corrupted DEXs to avoid DoS ##crash * Reported by Google clusterfuzz * Reproducer: clusterfuzz-testcase-minimized-ia_fuzz-5227091270959104 --- libr/bin/p/bin_dex.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libr/bin/p/bin_dex.c b/libr/bin/p/bin_dex.c index 0df1f9d8533ae..f518702bedcb9 100644 --- a/libr/bin/p/bin_dex.c +++ b/libr/bin/p/bin_dex.c @@ -267,8 +267,12 @@ static char *dex_get_proto(RBinDexObj *bin, int proto_id) { } size_t typeidx_bufsize = (list_size * sizeof (ut16)); if (params_off + typeidx_bufsize > bin->size) { + eprintf ("Warning: truncated typeidx buffer from %d to %d\n", + (int)(params_off + typeidx_bufsize), (int)(bin->size - params_off)); typeidx_bufsize = bin->size - params_off; - eprintf ("Warning: truncated typeidx buffer\n"); + // early return as this may result on so many trashy symbols that take too much time to load + // this is only happening when there's a corrupted dex. + return NULL; } RStrBuf *sig = r_strbuf_new ("("); if (typeidx_bufsize > 0) { From 3345147916b9bb3da225248d571cdbac690c0c4d Mon Sep 17 00:00:00 2001 From: pancake Date: Tue, 15 Feb 2022 12:46:20 +0100 Subject: [PATCH 022/390] Properly fix the UAF in r_io_bank_map_add_top ##crash * Associated with the CVE-2022-0559 * Reported by alkyne Choi via huntr.dev --- libr/io/io_bank.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/libr/io/io_bank.c b/libr/io/io_bank.c index 91f3bd1764eea..dc13c286b6251 100644 --- a/libr/io/io_bank.c +++ b/libr/io/io_bank.c @@ -227,20 +227,20 @@ R_API bool r_io_bank_map_add_top(RIO *io, const ut32 bankid, const ut32 mapid) { entry = r_rbnode_next (entry); } ut64 smto = r_io_submap_to (sm); - while (entry && r_io_submap_to (((RIOSubMap *)entry->data)) <= smto) { - //delete all submaps that are completly included in sm - RRBNode *next = r_rbnode_next (entry); - // this can be optimized, there is no need to do search here - // XXX this is a workaround to avoid an UAF in Reproducer: iobank-crash - void *smfree = bank->submaps->free; - bank->submaps->free = NULL; - bool a = r_crbtree_delete (bank->submaps, entry->data, _find_sm_by_from_vaddr_cb, NULL); - bank->submaps->free = smfree; - if (!a) { - entry = NULL; - break; + if (entry) { + ut64 ento = r_io_submap_to (((RIOSubMap*)entry->data)); + while (entry && ento <= smto) { + //delete all submaps that are completly included in sm + RRBNode *next = r_rbnode_next (entry); + // this can be optimized, there is no need to do search here + // XXX this is a workaround to avoid an UAF in Reproducer: iobank-crash + ento = r_io_submap_to (((RIOSubMap*)entry->data)); + bool a = r_crbtree_delete (bank->submaps, entry->data, _find_sm_by_from_vaddr_cb, NULL); + if (!a) { + next = NULL; + } + entry = next; } - entry = next; } if (entry && r_io_submap_from (((RIOSubMap *)entry->data)) <= r_io_submap_to (sm)) { bd = (RIOSubMap *)entry->data; From 90d4b07757f21fb67bc9a11b4113c2c924063756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20=C3=80lvarez=20i=20Capilla?= Date: Tue, 15 Feb 2022 13:31:20 +0100 Subject: [PATCH 023/390] Fix sorting of cr16 conditional bits --- libr/asm/arch/cr16/cr16_disas.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libr/asm/arch/cr16/cr16_disas.h b/libr/asm/arch/cr16/cr16_disas.h index b829aa761e48b..ec1679dac234e 100644 --- a/libr/asm/arch/cr16/cr16_disas.h +++ b/libr/asm/arch/cr16/cr16_disas.h @@ -134,14 +134,14 @@ enum cr16_conds { CR16_COND_GE, CR16_COND_CS, CR16_COND_CC, - CR16_COND_HI, CR16_COND_LS, - CR16_COND_LO, - CR16_COND_HS, + CR16_COND_HI, CR16_COND_GT, CR16_COND_LE, CR16_COND_FS, + CR16_COND_LO, CR16_COND_FC, + CR16_COND_HS, CR16_COND_LT, CR16_COND_UC, }; From 2984f4d4600b1fd6835da926dc7c4cefb7f0dee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20=C3=80lvarez=20i=20Capilla?= Date: Tue, 15 Feb 2022 14:46:50 +0100 Subject: [PATCH 024/390] Release 5.6.2 --- README.md | 2 +- configure | 16 ++++++++-------- configure.acr | 2 +- meson.build | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b98867d637937..7e7f7c95f7c11 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/741/badge)](https://bestpractices.coreinfrastructure.org/projects/741) [![Build Status](https://scan.coverity.com/projects/416/badge.svg)](https://scan.coverity.com/projects/416) [![Total alerts](https://img.shields.io/lgtm/alerts/g/radareorg/radare2.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/radareorg/radare2/alerts/) See the [Releases](https://github.com/radareorg/radare2/releases) page for -binary downloads. The current git `master` branch is `5.6.1`, and the next +binary downloads. The current git `master` branch is `5.6.3`, and the next major release will be `5.7.0`. r2 is a complete rewrite of radare. It provides a set of libraries, tools and diff --git a/configure b/configure index 569010593dc81..e44eb2fe8b750 100755 --- a/configure +++ b/configure @@ -134,12 +134,12 @@ done : ${INSTALL_PROGRAM_STRIP:=${INSTALL} -m 755 -s} : ${INSTALL_MAN:=${INSTALL} -m 444} : ${INSTALL_LIB:=${INSTALL} -m 755 -c} - PKGNAME='radare2' ; VERSION='5.6.1' ; VERSION_MAJOR=5; VERSION_MINOR=6; VERSION_PATCH=1; VERSION_NUMBER=50601; CONTACT_MAIL="pancake@nopcode.org" ; CONTACT_NAME="pancake" ; CONTACT="pancake " ; + PKGNAME='radare2' ; VERSION='5.6.2' ; VERSION_MAJOR=5; VERSION_MINOR=6; VERSION_PATCH=2; VERSION_NUMBER=50602; CONTACT_MAIL="pancake@nopcode.org" ; CONTACT_NAME="pancake" ; CONTACT="pancake " ; } show_usage() { cat <." exit 0 @@ -276,7 +276,7 @@ case $flag in show_version ; ;; -r|--r|--report) echo "PKGNAME: radare2" -echo "VERSION: 5.6.1" +echo "VERSION: 5.6.2" echo "LANGS: c" echo "REQUIRED: libdl" echo "OPTIONAL: libmagic libz libzip libxxhash libssl liblibuv>=1.0.0" @@ -373,7 +373,7 @@ parse_options "$1" shift done -ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR ETCDIR SYSCONFDIR DATADIR DOCDIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_NUMBER PKGNAME VPATH CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C DEBUGGER HAVE_LIB_DL DL_LIBS PKGCONFIG HAVE_PATCH PATCH HAVE_AR AR HAVE_GIT GIT HAVE_GPERF GPERF HAVE_LIB_MAGIC USE_MAGIC USE_LIB_MAGIC LIBMAGIC WANT_THREADS LOADLIBS WANT_DYLINK HAVE_FORK WANT_PTRACE_WRAP WANT_GPERF WANT_CAPSTONE WITH_LIBR USE_CS5 USE_CS4 WITH_CAPSTONE CAPSTONE_CFLAGS CAPSTONE_LDFLAGS HAVE_PKGCFG_CAPSTONE USE_CAPSTONE LZ4_CFLAGS LZ4_LDFLAGS HAVE_PKGCFG_LIBLZ4 WITH_SYSLZ4 USE_LIB_LZ4 HAVE_LIB_Z HAVE_LIB_ZIP USE_ZIP USE_LIB_ZIP LIBZIP HAVE_LIB_XXHASH USE_XXHASH USE_LIB_XXHASH LIBXXHASH WITH_GPL HAVE_DECL_ADDR_NO_RANDOMIZE HAVE_DECL___GLIBC__ HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET HAVE_CLOCK_NANOSLEEP HAVE_SIGACTION HAVE_CLOCK_GETTIME CLOCK_LDFLAGS SUPPORT_GNU99 HAVE_LIB_GMP HAVE_LIB_SSL SSL_CFLAGS SSL_LDFLAGS HAVE_PKGCFG_OPENSSL HAVE_OPENSSL WANT_OPENSSL HAVE_LIBUV_VERSION_1_0_0 LIBUV_CFLAGS LIBUV_LDFLAGS HAVE_PKGCFG_LIBUV HAVE_LIBUV WANT_LIBUV USE_RPATH USERCC USEROSTYPE LIBVERSION HAVE_JEMALLOC HAVE_PTRACE USE_PTRACE_WRAP R_CHECKS_LEVEL" +ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR ETCDIR SYSCONFDIR DATADIR DOCDIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_NUMBER PKGNAME VPATH CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C DEBUGGER HAVE_LIB_DL DL_LIBS PKGCONFIG HAVE_PATCH PATCH HAVE_AR AR HAVE_GIT GIT HAVE_GPERF GPERF HAVE_LIB_MAGIC USE_MAGIC USE_LIB_MAGIC LIBMAGIC WANT_THREADS LOADLIBS WANT_DYLINK HAVE_FORK WANT_PTRACE_WRAP WANT_GPERF WANT_CAPSTONE WITH_LIBR USE_CS5 USE_CS4 WITH_CAPSTONE CAPSTONE_CFLAGS CAPSTONE_LDFLAGS HAVE_PKGCFG_CAPSTONE USE_CAPSTONE LZ4_CFLAGS LZ4_LDFLAGS HAVE_PKGCFG_LIBLZ4 WITH_SYSLZ4 USE_SYSLZ4 HAVE_LIB_Z HAVE_LIB_ZIP USE_ZIP USE_LIB_ZIP LIBZIP HAVE_LIB_XXHASH USE_XXHASH USE_LIB_XXHASH LIBXXHASH WITH_GPL HAVE_DECL_ADDR_NO_RANDOMIZE HAVE_DECL___GLIBC__ HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET HAVE_CLOCK_NANOSLEEP HAVE_SIGACTION HAVE_CLOCK_GETTIME CLOCK_LDFLAGS SUPPORT_GNU99 HAVE_LIB_GMP HAVE_LIB_SSL SSL_CFLAGS SSL_LDFLAGS HAVE_PKGCFG_OPENSSL HAVE_OPENSSL WANT_OPENSSL HAVE_LIBUV_VERSION_1_0_0 LIBUV_CFLAGS LIBUV_LDFLAGS HAVE_PKGCFG_LIBUV HAVE_LIBUV WANT_LIBUV USE_RPATH USERCC USEROSTYPE LIBVERSION HAVE_JEMALLOC HAVE_PTRACE USE_PTRACE_WRAP R_CHECKS_LEVEL" create_environ @@ -617,9 +617,9 @@ echo yes; HAVE_PKGCFG_LIBLZ4=1; LZ4_LDFLAGS=$tmp; fi; fi if [ 11 = "$WITH_SYSLZ4$LZ4_CFLAGS" ]; then -USE_LIB_LZ4="1" +USE_SYSLZ4="1" else -USE_LIB_LZ4="0"; fi +USE_SYSLZ4="0"; fi check_library HAVE_LIB_Z z 0 check_library HAVE_LIB_ZIP zip 0 if [ 11 = "$HAVE_LIB_Z$USE_ZIP" ]; then diff --git a/configure.acr b/configure.acr index 53eb58b8259d2..74e5eebed6b81 100644 --- a/configure.acr +++ b/configure.acr @@ -1,5 +1,5 @@ PKGNAME radare2 -VERSION 5.6.1 +VERSION 5.6.2 CONTACT pancake ; pancake@nopcode.org LANG_C! diff --git a/meson.build b/meson.build index 29a7e725678bc..75e1648b06c2c 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('radare2', 'c', license : 'LGPL3', meson_version : '>=0.49', version : '5.6.1') +project('radare2', 'c', license : 'LGPL3', meson_version : '>=0.49', version : '5.6.2') py3_exe = import('python').find_installation('python3') git_exe = find_program('git', required: false) From 4a11460c9d22b06e7bd327f44a08c8927c733b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20=C3=80lvarez=20i=20Capilla?= Date: Tue, 15 Feb 2022 22:54:08 +0100 Subject: [PATCH 025/390] Build fixes for wasi/wapm/wasm and update sdb ##build --- dist/wapm/wapm.toml | 2 +- libr/anal/esil.c | 2 +- libr/include/heap/r_jemalloc/internal/jemalloc_internal.h | 3 +++ libr/util/file.c | 6 +++--- libr/util/sys.c | 4 ++++ shlr/sdb/Makefile | 2 +- shlr/sdb/config.mk | 2 +- shlr/sdb/src/disk.c | 4 ++-- shlr/sdb/src/lock.c | 2 +- shlr/sdb/src/main.c | 2 +- shlr/sdb/src/types.h | 2 +- 11 files changed, 19 insertions(+), 12 deletions(-) diff --git a/dist/wapm/wapm.toml b/dist/wapm/wapm.toml index c030b69bdeef3..61c2c02a625e5 100644 --- a/dist/wapm/wapm.toml +++ b/dist/wapm/wapm.toml @@ -1,6 +1,6 @@ [package] name = "pancake/r2" -version = "5.4.4" +version = "5.6.2" description = "Unix-Like Reverse Engineering Framework" readme = "README.md" license = "LGPL3" diff --git a/libr/anal/esil.c b/libr/anal/esil.c index 5f29c7809d304..309de42f463db 100644 --- a/libr/anal/esil.c +++ b/libr/anal/esil.c @@ -5,7 +5,7 @@ #include #include -#ifdef __wasi__ +#if __wasi__ || EMSCRIPTEN #define FE_OVERFLOW 0 #define feclearexcept(x) #endif diff --git a/libr/include/heap/r_jemalloc/internal/jemalloc_internal.h b/libr/include/heap/r_jemalloc/internal/jemalloc_internal.h index 84b9e2e5cdbe7..85207d9f46c18 100644 --- a/libr/include/heap/r_jemalloc/internal/jemalloc_internal.h +++ b/libr/include/heap/r_jemalloc/internal/jemalloc_internal.h @@ -284,6 +284,9 @@ typedef unsigned szind_t; # ifdef __tile__ # define LG_QUANTUM 4 # endif +# ifdef EMSCRIPTEN +# define LG_QUANTUM 4 +# endif # ifdef __WASM__ # define LG_QUANTUM 4 # endif diff --git a/libr/util/file.c b/libr/util/file.c index 6a9c2341d59e8..4b92a3e93dc05 100644 --- a/libr/util/file.c +++ b/libr/util/file.c @@ -900,7 +900,7 @@ R_API int r_file_mmap_write(const char *file, ut64 addr, const ut8 *buf, int len CloseHandle (fh); } return ret; -#elif __wasi__ +#elif __wasi__ || EMSCRIPTEN return -1; #elif __UNIX__ int fd = r_sandbox_open (file, RDWR_FLAGS, 0644); @@ -965,7 +965,7 @@ R_API int r_file_mmap_read(const char *file, ut64 addr, ut8 *buf, int len) { } free (file_); return ret; -#elif __wasi__ +#elif __wasi__ || EMSCRIPTEN return 0; #elif __UNIX__ int fd = r_sandbox_open (file, O_RDONLY, 0644); @@ -989,7 +989,7 @@ R_API int r_file_mmap_read(const char *file, ut64 addr, ut8 *buf, int len) { #endif } -#if __wasi__ +#if __wasi__ || EMSCRIPTEN static RMmap *r_file_mmap_unix(RMmap *m, int fd) { return NULL; } diff --git a/libr/util/sys.c b/libr/util/sys.c index a1b15c536de93..a4556743879f7 100644 --- a/libr/util/sys.c +++ b/libr/util/sys.c @@ -440,7 +440,11 @@ static void signal_handler(int signum) { if (!crash_handler_cmd) { return; } +#if __wasi__ || EMSCRIPTEN + char *cmd = r_str_newf ("%s %d", crash_handler_cmd, 0); +#else char *cmd = r_str_newf ("%s %d", crash_handler_cmd, r_sys_getpid ()); +#endif int rc = 1; if (cmd) { r_sys_backtrace (); diff --git a/shlr/sdb/Makefile b/shlr/sdb/Makefile index 2537e6cc9b7fc..b3b4365fb4848 100644 --- a/shlr/sdb/Makefile +++ b/shlr/sdb/Makefile @@ -28,7 +28,7 @@ include wasi.mk wasi wasm: $(WASI_SDK) ${MAKE} src/sdb_version.h - CC=$(WASI_CC) CFLAGS="$(WASI_CFLAGS)" $(MAKE) -C src all WITHPIC=0 + CC=$(WASI_CC) CFLAGS="$(WASI_CFLAGS)" $(MAKE) CC=$(WASI_CC) -C src all WITHPIC=0 mv src/sdb src/sdb.wasm file src/sdb.wasm diff --git a/shlr/sdb/config.mk b/shlr/sdb/config.mk index c0c2fb49b6496..b896d45b86b8d 100644 --- a/shlr/sdb/config.mk +++ b/shlr/sdb/config.mk @@ -6,7 +6,7 @@ INCDIR=${PREFIX}/include VAPIDIR=${DATADIR}/vala/vapi/ MANDIR=${DATADIR}/man/man1 -SDBVER=1.8.4 +SDBVER=1.8.5 BUILD_MEMCACHE=0 diff --git a/shlr/sdb/src/disk.c b/shlr/sdb/src/disk.c index af035413cfd7f..4a5dfbf70b095 100644 --- a/shlr/sdb/src/disk.c +++ b/shlr/sdb/src/disk.c @@ -70,7 +70,7 @@ static inline int r_sys_mkdirp(char *dir) { while ((ptr = strchr (ptr, slash))) { *ptr = 0; if (!r_sys_mkdir (path) && r_sys_mkdir_failed ()) { - eprintf ("r_sys_mkdirp: fail '%s' of '%s'\n", path, dir); + // eprintf ("r_sys_mkdirp: fail '%s' of '%s'\n", path, dir); *ptr = slash; return 0; } @@ -115,7 +115,7 @@ SDB_API bool sdb_disk_create(Sdb* s) { s->fdump = open (str, O_BINARY | O_RDWR | O_CREAT | O_TRUNC, SDB_MODE); #endif if (s->fdump == -1) { - eprintf ("sdb: Cannot open '%s' for writing.\n", str); + // eprintf ("sdb: Cannot open '%s' for writing.\n", str); free (str); return false; } diff --git a/shlr/sdb/src/lock.c b/shlr/sdb/src/lock.c index c6338e50c6d70..58acf07ee5f00 100644 --- a/shlr/sdb/src/lock.c +++ b/shlr/sdb/src/lock.c @@ -4,7 +4,7 @@ #include #include #include "sdb.h" -#ifdef __wasi__ +#if __wasi__ || EMSCRIPTEN static int getpid(void) { return 0; } #endif diff --git a/shlr/sdb/src/main.c b/shlr/sdb/src/main.c index 1899afb575fec..0383cbb147adf 100644 --- a/shlr/sdb/src/main.c +++ b/shlr/sdb/src/main.c @@ -764,7 +764,7 @@ static int gen_gperf(MainOptions *mo, const char *file, const char *name) { } int rc = -1; if (wd != -1) { -#ifdef __wasi__ +#if __wasi__ || EMSCRIPTEN rc = sdb_dump (mo); // file, MODE_CGEN, false, NULL); fflush (stdout); #else diff --git a/shlr/sdb/src/types.h b/shlr/sdb/src/types.h index 7828a65676d92..dbb70809cfe26 100644 --- a/shlr/sdb/src/types.h +++ b/shlr/sdb/src/types.h @@ -63,7 +63,7 @@ #define ULLFMT "ll" #endif -#if __wasi__ +#if __wasi__ || EMSCRIPTEN #undef HAVE_MMAN #define HAVE_MMAN 0 #endif From 99a3887e6a39627391b3bbe86ce26521947b51da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20=C3=80lvarez=20i=20Capilla?= Date: Tue, 15 Feb 2022 23:19:35 +0100 Subject: [PATCH 026/390] Add rasm2 and rax2 wasi/wapm packages ##build * wapm install pancake/r2 $ wapm run r2 - * wapm install pancake/rax2 $ wapm run rax2 1+1 * wapm install pancake/rasm2 $ wapm run rasm2 -a x86 -b 32 -d 90 --- dist/wapm/Makefile | 6 ------ dist/wapm/r2/Makefile | 7 +++++++ dist/wapm/{ => r2}/README.md | 0 dist/wapm/{ => r2}/wapm.toml | 0 dist/wapm/rasm2/Makefile | 7 +++++++ dist/wapm/rasm2/README.md | 1 + dist/wapm/rasm2/wapm.toml | 18 ++++++++++++++++++ dist/wapm/rax2/Makefile | 7 +++++++ dist/wapm/rax2/README.md | 1 + dist/wapm/rax2/wapm.toml | 15 +++++++++++++++ libr/core/cmd_write.c | 2 +- libr/include/heap/r_jemalloc/internal/nstime.h | 6 ------ 12 files changed, 57 insertions(+), 13 deletions(-) delete mode 100644 dist/wapm/Makefile create mode 100644 dist/wapm/r2/Makefile rename dist/wapm/{ => r2}/README.md (100%) rename dist/wapm/{ => r2}/wapm.toml (100%) create mode 100644 dist/wapm/rasm2/Makefile create mode 100644 dist/wapm/rasm2/README.md create mode 100644 dist/wapm/rasm2/wapm.toml create mode 100644 dist/wapm/rax2/Makefile create mode 100644 dist/wapm/rax2/README.md create mode 100644 dist/wapm/rax2/wapm.toml diff --git a/dist/wapm/Makefile b/dist/wapm/Makefile deleted file mode 100644 index 628a442c8e824..0000000000000 --- a/dist/wapm/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -all: r2.wasm - # wapm login - wapm publish - -r2.wasm: - cp ../../radare2-*-wasi/radare2.wasm.o3.wasm r2.wasm diff --git a/dist/wapm/r2/Makefile b/dist/wapm/r2/Makefile new file mode 100644 index 0000000000000..50d7858ad06f2 --- /dev/null +++ b/dist/wapm/r2/Makefile @@ -0,0 +1,7 @@ +all: r2.wasm + vim wapm.toml + # wapm login + wapm publish + +r2.wasm: + cp -f ../../../radare2-*-wasi/radare2.wasm.o3.wasm r2.wasm diff --git a/dist/wapm/README.md b/dist/wapm/r2/README.md similarity index 100% rename from dist/wapm/README.md rename to dist/wapm/r2/README.md diff --git a/dist/wapm/wapm.toml b/dist/wapm/r2/wapm.toml similarity index 100% rename from dist/wapm/wapm.toml rename to dist/wapm/r2/wapm.toml diff --git a/dist/wapm/rasm2/Makefile b/dist/wapm/rasm2/Makefile new file mode 100644 index 0000000000000..261fae288ee91 --- /dev/null +++ b/dist/wapm/rasm2/Makefile @@ -0,0 +1,7 @@ +all: rasm2.wasm + vim wapm.toml + # wapm login + wapm publish + +rasm2.wasm: + cp -f ../../../radare2-*-wasi/rasm2.wasm.o3.wasm rasm2.wasm diff --git a/dist/wapm/rasm2/README.md b/dist/wapm/rasm2/README.md new file mode 100644 index 0000000000000..ee487f05f4ff9 --- /dev/null +++ b/dist/wapm/rasm2/README.md @@ -0,0 +1 @@ +wasi build of rasm2 assembler/disassembler (part of the radare2 project) diff --git a/dist/wapm/rasm2/wapm.toml b/dist/wapm/rasm2/wapm.toml new file mode 100644 index 0000000000000..3a5cc8e45f899 --- /dev/null +++ b/dist/wapm/rasm2/wapm.toml @@ -0,0 +1,18 @@ +[package] +name = "pancake/rasm2" +version = "5.6.2" +description = "Unix-Like Reverse Engineering Framework" +license = "LGPL3" +readme = "README.md" + +[dependencies] +"pancake/rasm2" = "5.6.2" + +[[module]] +name = "rasm2" +source = "rasm2.wasm" +abi = "wasi" + +[[command]] +name = "rasm2" +module = "rasm2" diff --git a/dist/wapm/rax2/Makefile b/dist/wapm/rax2/Makefile new file mode 100644 index 0000000000000..31c0c3566e2c1 --- /dev/null +++ b/dist/wapm/rax2/Makefile @@ -0,0 +1,7 @@ +all: rax2.wasm + vim wapm.toml + # wapm login + wapm publish + +rax2.wasm: + cp -f ../../../radare2-*-wasi/rax2.wasm.o3.wasm rax2.wasm diff --git a/dist/wapm/rax2/README.md b/dist/wapm/rax2/README.md new file mode 100644 index 0000000000000..fe4905a6b7bee --- /dev/null +++ b/dist/wapm/rax2/README.md @@ -0,0 +1 @@ +wasi build of rax2 calculator (part of the radare2 project) diff --git a/dist/wapm/rax2/wapm.toml b/dist/wapm/rax2/wapm.toml new file mode 100644 index 0000000000000..f2b30d423d2e6 --- /dev/null +++ b/dist/wapm/rax2/wapm.toml @@ -0,0 +1,15 @@ +[package] +name = "pancake/rax2" +version = "5.6.2" +description = "Unix-Like Reverse Engineering Framework" +readme = "README.md" +license = "LGPL3" + +[[module]] +name = "rax2" +abi = "wasi" +source = "rax2.wasm" + +[[command]] +name = "rax2" +module = "rax2" diff --git a/libr/core/cmd_write.c b/libr/core/cmd_write.c index f34375966cd23..1b83aeddbade5 100644 --- a/libr/core/cmd_write.c +++ b/libr/core/cmd_write.c @@ -182,8 +182,8 @@ static const char *help_msg_wv[] = { static const char *help_msg_wx[] = { "Usage:", "wx[f] [arg]", "", "wx", " 9090", "write two intel nops", - "wxf", " -|file", "write contents of hexpairs file here", "wx+", " 9090", "write hexpairs and seek forward", + "wxf", " -|file", "write contents of hexpairs file here", NULL }; diff --git a/libr/include/heap/r_jemalloc/internal/nstime.h b/libr/include/heap/r_jemalloc/internal/nstime.h index bf0cd048db967..93b27dc80a055 100644 --- a/libr/include/heap/r_jemalloc/internal/nstime.h +++ b/libr/include/heap/r_jemalloc/internal/nstime.h @@ -1,12 +1,6 @@ /******************************************************************************/ #ifdef JEMALLOC_H_TYPES -#ifdef __wasi__ -// #define nstime_t time_t -#undef JM_NBINS -#define JM_NBINS 1 -#endif - typedef struct nstime_s nstime_t; /* Maximum supported number of seconds (~584 years). */ From 33ce7e78a25044773741cd85f566a26ffa5f0f5c Mon Sep 17 00:00:00 2001 From: pancake Date: Sun, 13 Feb 2022 19:18:10 +0100 Subject: [PATCH 027/390] Add initial support for katakana ##charset * Support multibyte charsets --- libr/util/Makefile | 2 + libr/util/charset.c | 77 ++++++++++++++++++++++------- libr/util/d/Makefile | 2 +- libr/util/d/hiragana.sdb.txt | 87 +++++++++++++++++++++++++++++++++ libr/util/d/katakana.sdb.txt | 93 ++++++++++++++++++++++++++++++++++++ libr/util/d/meson.build | 2 + test/db/cmd/charset | 19 ++++++++ 7 files changed, 264 insertions(+), 18 deletions(-) create mode 100644 libr/util/d/hiragana.sdb.txt create mode 100644 libr/util/d/katakana.sdb.txt diff --git a/libr/util/Makefile b/libr/util/Makefile index 5a76fef1472fc..8e2555edb3ee9 100644 --- a/libr/util/Makefile +++ b/libr/util/Makefile @@ -19,6 +19,8 @@ OBJS+=ascii_table.o protobuf.o graph_drawable.o axml.o sstext.o new_rbtree.o ifeq (${HAVE_GPERF},1) OBJS+=d/ascii.o OBJS+=d/pokered.o +OBJS+=d/katakana.o +OBJS+=d/hiragana.o OBJS+=d/ebcdic37.o OBJS+=d/iso8859_1.o endif diff --git a/libr/util/charset.c b/libr/util/charset.c index d7816f32479b1..4c252e08c7445 100644 --- a/libr/util/charset.c +++ b/libr/util/charset.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2020-2021 - gogo, pancake */ +/* radare - LGPL - Copyright 2020-2022 - gogo, pancake */ #include #include @@ -7,15 +7,19 @@ #if HAVE_GPERF extern SdbGperf gperf_ascii; -extern SdbGperf gperf_pokered; extern SdbGperf gperf_ebcdic37; +extern SdbGperf gperf_hiragana; extern SdbGperf gperf_iso8859_1; +extern SdbGperf gperf_katakana; +extern SdbGperf gperf_pokered; static const SdbGperf *gperfs[] = { &gperf_ascii, - &gperf_pokered, &gperf_ebcdic37, + &gperf_hiragana, &gperf_iso8859_1, + &gperf_katakana, + &gperf_pokered, NULL }; @@ -223,6 +227,7 @@ R_API size_t r_charset_encode_str(RCharset *rc, ut8 *out, size_t out_len, const } fine = true; r_str_unescape (res); + // memcpy (o, res, out_len - i); r_str_ncpy (o, res, out_len - i); free (res); } @@ -250,33 +255,71 @@ R_API size_t r_charset_decode_str(RCharset *rc, ut8 *out, size_t out_len, const if (!str) { break; } - r_str_ncpy (str, (char *)in + cur, toread); + memcpy (str, in + cur, toread); bool found = false; for (j = toread; cur < in_len && j > 0; j--) { left = in_len - cur + 1; toread = R_MIN (left, maxkeylen); - //zero terminate the string - str[j] = '\0'; - + str[j] = 0; const char *v = sdb_const_get (rc->db_char_to_hex, (char *) str, 0); if (v) { + int repeat = !strncmp (v, "0x", 2)? strlen (v + 2) / 2: 1; + ut64 nv = r_num_get (NULL, v); + if (!nv) { + int i; + // write 0x00 N times ( + for (i = 0; i < repeat; i++) { + // write null byte + memcpy (o, "\x00", 2); + o++; + } + o--; + found = true; + break; + } //convert to ascii char *str_hx = malloc (1 + maxkeylen); if (!str_hx) { break; } - //in the future handle multiple chars output - snprintf (str_hx, maxkeylen + 1, "%c", (char) strtol (v, 0, 16)); - const char *ret = r_str_get_fail (str_hx, "?"); + if (nv > 0xff) { + ut64 d = 0; + r_mem_swapendian ((ut8*)&d, (const ut8*)&nv, 8); + nv = d; + } + int i; + bool skip = true; + int chcount = 0; + for (i = 0; i < 8; i++) { + ut8 bv = nv & 0xff; + // skip until we found one byet + if (bv & 0xff) { + skip = false; + } + if (skip) { + nv >>= 8; + continue; + } else if (!bv) { + break; + } + // eprintf ("-> 0x%02x\n", nv & 0xff); + //in the future handle multiple chars output + str_hx[0] = bv; + str_hx[1] = 0; + const char *ret = r_str_get_fail (str_hx, "?"); - // concatenate - const size_t ll = R_MIN (left, strlen (ret) + 1); - if (ll > 0) { - r_str_ncpy (o, ret, ll); - o += ll - 1; + // concatenate + const size_t ll = R_MIN (left, strlen (ret) + 1); + if (ll > 0) { + memcpy (o, ret, ll); + o[ll] = 0; + o += ll - 1; + chcount++; + } + found = true; + nv >>= 8; } - found = true; - cur += j - 1; + cur += (chcount>1)?chcount - 2:j-1; free (str_hx); break; } diff --git a/libr/util/d/Makefile b/libr/util/d/Makefile index ac0502dce7256..e740ab2f120df 100644 --- a/libr/util/d/Makefile +++ b/libr/util/d/Makefile @@ -1,4 +1,4 @@ -FILES=pokered ascii ebcdic37 iso8859_1 +FILES=pokered ascii ebcdic37 iso8859_1 katakana hiragana F_SDB=$(addsuffix .sdb,$(FILES)) SDB=../../../shlr/sdb/sdb diff --git a/libr/util/d/hiragana.sdb.txt b/libr/util/d/hiragana.sdb.txt new file mode 100644 index 0000000000000..deaf5f55acc7b --- /dev/null +++ b/libr/util/d/hiragana.sdb.txt @@ -0,0 +1,87 @@ +# define utf8-phoneme translation for Japanese's Hiragana charset +0xa= +0xe38181=a +0xe38182=A +0xe38183=i +0xe38184=I +0xe38185=u +0xe38186=U +0xe38187=e +0xe38188=E +0xe38189=o +0xe3818a=O +0xe3818b=ka +0xe3818c=ga +0xe3818d=ki +0xe3818e=gi +0xe3818f=ku +0xe38190=gu +0xe38191=ke +0xe38192=ge +0xe38193=ko +0xe38194=go +0xe38195=sa +0xe38196=za +0xe38197=si +0xe38198=zi +0xe38199=su +0xe3819a=zu +0xe3819b=se +0xe3819c=ze +0xe3819d=so +0xe3819e=zo +0xe3819f=ta +0xe381a0=da +0xe381a1=ti +0xe381a2=di +0xe381a3=tu +0xe381a4=du +0xe381a5=tu +0xe381a6=du +0xe381a6=te +0xe381a7=de +0xe381a8=to +0xe381a9=do +0xe381aa=na +0xe381ab=ni +0xe381ac=nu +0xe381ad=ne +0xe381ae=no +0xe381af=ha +0xe381b0=ba +0xe381b1=pa +0xe381b2=hi +0xe381b3=bi +0xe381b4=pi +0xe381b5=hu +0xe381b6=bu +0xe381b7=pu +0xe381b8=he +0xe381b9=be +0xe381ba=pe +0xe381bb=ho +0xe381bc=bo +0xe381bd=po +0xe381be=ma +0xe381bf=mi +# unicode hole +0xe38280=mu +0xe38281=me +0xe38282=mo +0xe38283=ya +0xe38284=YA +0xe38285=yu +0xe38286=YU +0xe38287=yo +0xe38288=YO +0xe38289=ra +0xe3828a=ri +0xe3828b=ru +0xe3828c=re +0xe3828d=ro +0xe3828e=wa +0xe3828f=WA +0xe38290=wi +0xe38291=we +0xe38292=wo +0xe38293=n diff --git a/libr/util/d/katakana.sdb.txt b/libr/util/d/katakana.sdb.txt new file mode 100644 index 0000000000000..d8abd9d1c1527 --- /dev/null +++ b/libr/util/d/katakana.sdb.txt @@ -0,0 +1,93 @@ +# define utf8-phoneme translation for Japanese's Katakana charset +0xa= +0xe382a1=a +0xe382a2=A +0xe382a3=i +0xe382a4=I +0xe382a5=u +0xe382a6=U +0xe382a7=e +0xe382a8=E +0xe382a9=o +0xe382aa=O +0xe382ab=ka +0xe382ac=ga +0xe382ad=ki +0xe382ae=gi +0xe382af=ku +0xe382b0=gu +0xe382b1=ke +0xe382b2=ge +0xe382b3=ko +0xe382b4=go +0xe382b5=sa +0xe382b6=za +0xe382b7=si +0xe382b8=zi +0xe382b9=su +0xe382ba=zu +0xe382bb=se +0xe382bc=ze +0xe382bd=so +0xe382be=zo +0xe382bf=ta +## unicode hole +0xe38380=da +0xe38381=ti +0xe38382=di +0xe38383=tu +0xe38384=du +0xe38385=tu +0xe38386=du +0xe38386=te +0xe38387=de +0xe38388=to +0xe38389=do +0xe3838a=na +0xe3838b=ni +0xe3838c=nu +0xe3838d=ne +0xe3838e=no +0xe3838f=ha +0xe38390=ba +0xe38391=pa +0xe38392=hi +0xe38393=bi +0xe38394=pi +0xe38395=hu +0xe38396=bu +0xe38397=pu +0xe38398=he +0xe38399=be +0xe3839a=pe +0xe3839b=ho +0xe3839c=bo +0xe3839d=po +0xe3839e=ma +0xe3839f=mi +0xe383a0=mu +0xe383a1=me +0xe383a2=mo +0xe383a3=ya +0xe383a4=YA +0xe383a5=yu +0xe383a6=YU +0xe383a7=yo +0xe383a8=YO +0xe383a9=ra +0xe383aa=ri +0xe383ab=ru +0xe383ac=re +0xe383ad=ro +0xe383ae=wa +0xe383af=WA +0xe383b0=wi +0xe383b1=we +0xe383b2=wo +0xe383b3=n +0xe383b4=vu +0xe383b5=ka +0xe383b6=ke +# another hole +0xe3829b=" +0xe3829c=. diff --git a/libr/util/d/meson.build b/libr/util/d/meson.build index 5ed85d330090e..e5d8966d9e111 100644 --- a/libr/util/d/meson.build +++ b/libr/util/d/meson.build @@ -2,6 +2,8 @@ sdb_files = [ 'pokered', 'ebcdic37', 'ascii', + 'katakana', + 'hiragana', 'iso8859_1' ] diff --git a/test/db/cmd/charset b/test/db/cmd/charset index 9fd6327cadfbf..68b45bf87c3a7 100644 --- a/test/db/cmd/charset +++ b/test/db/cmd/charset @@ -71,7 +71,9 @@ EOF EXPECT=<itself-fr @@ -95,14 +97,18 @@ EOF EXPECT=< Date: Wed, 16 Feb 2022 16:55:24 +0100 Subject: [PATCH 028/390] Run some tests in freebsd (#19723) --- .github/workflows/freebsd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index 1fd7d159c2e41..c5d9d4fff6ac9 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -29,6 +29,7 @@ jobs: sys/install.sh gmake install DESTDIR=/tmp/prefix (cd /tmp/prefix ; tar czvf /tmp/radare2-freebsd.tgz *) + r2r test/db/cmd rm -rf * cp /tmp/radare2-freebsd.tgz . echo DATE: ; date From a7386c4b832c3d413e0229443561c5299c0884ef Mon Sep 17 00:00:00 2001 From: pancake Date: Fri, 18 Feb 2022 01:49:26 +0100 Subject: [PATCH 029/390] After release version bump --- .github/workflows/freebsd.yml | 2 +- README.md | 2 +- configure | 10 +++++----- configure.acr | 2 +- meson.build | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index c5d9d4fff6ac9..1fd68f7ac1b34 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -17,7 +17,7 @@ jobs: uses: vmactions/freebsd-vm@v0.1.6 with: usesh: true - prepare: pkg install -y curl gmake patch git + prepare: pkg install -y curl gmake patch git python gawk run: | cd work || true pwd diff --git a/README.md b/README.md index 7e7f7c95f7c11..dae5e118c5094 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ See the [Releases](https://github.com/radareorg/radare2/releases) page for binary downloads. The current git `master` branch is `5.6.3`, and the next -major release will be `5.7.0`. +release will be `5.6.4`. r2 is a complete rewrite of radare. It provides a set of libraries, tools and plugins to ease reverse engineering tasks. diff --git a/configure b/configure index e44eb2fe8b750..c22b54eb1a2c2 100755 --- a/configure +++ b/configure @@ -134,12 +134,12 @@ done : ${INSTALL_PROGRAM_STRIP:=${INSTALL} -m 755 -s} : ${INSTALL_MAN:=${INSTALL} -m 444} : ${INSTALL_LIB:=${INSTALL} -m 755 -c} - PKGNAME='radare2' ; VERSION='5.6.2' ; VERSION_MAJOR=5; VERSION_MINOR=6; VERSION_PATCH=2; VERSION_NUMBER=50602; CONTACT_MAIL="pancake@nopcode.org" ; CONTACT_NAME="pancake" ; CONTACT="pancake " ; + PKGNAME='radare2' ; VERSION='5.6.3' ; VERSION_MAJOR=5; VERSION_MINOR=6; VERSION_PATCH=3; VERSION_NUMBER=50603; CONTACT_MAIL="pancake@nopcode.org" ; CONTACT_NAME="pancake" ; CONTACT="pancake " ; } show_usage() { cat <." exit 0 @@ -276,7 +276,7 @@ case $flag in show_version ; ;; -r|--r|--report) echo "PKGNAME: radare2" -echo "VERSION: 5.6.2" +echo "VERSION: 5.6.3" echo "LANGS: c" echo "REQUIRED: libdl" echo "OPTIONAL: libmagic libz libzip libxxhash libssl liblibuv>=1.0.0" diff --git a/configure.acr b/configure.acr index 74e5eebed6b81..597db81bf0b87 100644 --- a/configure.acr +++ b/configure.acr @@ -1,5 +1,5 @@ PKGNAME radare2 -VERSION 5.6.2 +VERSION 5.6.3 CONTACT pancake ; pancake@nopcode.org LANG_C! diff --git a/meson.build b/meson.build index 75e1648b06c2c..b988210bdfa2a 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('radare2', 'c', license : 'LGPL3', meson_version : '>=0.49', version : '5.6.2') +project('radare2', 'c', license : 'LGPL3', meson_version : '>=0.49', version : '5.6.3') py3_exe = import('python').find_installation('python3') git_exe = find_program('git', required: false) From f59b7dfb5628445a073283467af5beed40a45a85 Mon Sep 17 00:00:00 2001 From: aemmitt Date: Thu, 17 Feb 2022 22:12:03 -0500 Subject: [PATCH 030/390] fix the arm64 sdiv and udiv instrs on div by 0 --- libr/anal/p/anal_arm_cs.c | 9 +++++++-- libr/anal/p/anal_arm_v35.c | 8 +++++++- libr/anal/p/anal_x86_cs.c | 6 ++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/libr/anal/p/anal_arm_cs.c b/libr/anal/p/anal_arm_cs.c index ee57d55df7882..418686ff56096 100644 --- a/libr/anal/p/anal_arm_cs.c +++ b/libr/anal/p/anal_arm_cs.c @@ -1619,11 +1619,16 @@ static int analop64_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int l FPOPCALL ("/"); break; case ARM64_INS_SDIV: - OPCALL_SIGN ("/", REGBITS64 (1)); + r_strbuf_setf (&op->esil, "%s,!,?{,0,%s,=,}{,", REG64 (2), REG64 (0)); + OPCALL_SIGN ("~/", REGBITS64 (1)); + r_strbuf_appendf (&op->esil, ",}"); break; case ARM64_INS_UDIV: /* TODO: support WZR XZR to specify 32, 64bit op */ - OPCALL ("/"); + // arm64 does not have a div-by-zero exception, just quietly sets R0 to 0 + r_strbuf_setf (&op->esil, "%s,!,?{,0,%s,=,}{,", REG64 (2), REG64 (0)); + OPCALL("/"); + r_strbuf_appendf (&op->esil, ",}"); break; #if CS_API_MAJOR > 4 case ARM64_INS_BRAA: diff --git a/libr/anal/p/anal_arm_v35.c b/libr/anal/p/anal_arm_v35.c index 169065317f4c7..c4a119bf08201 100644 --- a/libr/anal/p/anal_arm_v35.c +++ b/libr/anal/p/anal_arm_v35.c @@ -1580,11 +1580,17 @@ static int analop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len FPOPCALL("/"); break; case ARM64_SDIV: - OPCALL_SIGN("/", REGBITS64 (1)); + // arm64 does not have a div-by-zero exception, just quietly sets R0 to 0 + r_strbuf_setf (&op->esil, "%s,!,?{,0,%s,=,}{,", REG64 (2), REG64 (0)); + OPCALL_SIGN ("~/", REGBITS64 (1)); + r_strbuf_appendf (&op->esil, ",}"); break; case ARM64_UDIV: /* TODO: support WZR XZR to specify 32, 64bit op */ + // arm64 does not have a div-by-zero exception, just quietly sets R0 to 0 + r_strbuf_setf (&op->esil, "%s,!,?{,0,%s,=,}{,", REG64 (2), REG64 (0)); OPCALL("/"); + r_strbuf_appendf (&op->esil, ",}"); break; // TODO actually implement some kind of fake PAC or at least clear the bits // PAC B* instructions will not work without clearing PAC bits diff --git a/libr/anal/p/anal_x86_cs.c b/libr/anal/p/anal_x86_cs.c index 97471bb67490d..0bb4407019b3f 100644 --- a/libr/anal/p/anal_x86_cs.c +++ b/libr/anal/p/anal_x86_cs.c @@ -999,9 +999,15 @@ static void anop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, case X86_INS_CWDE: esilprintf (op, "ax,eax,=,15,eax,>>,?{,0xffff0000,eax,|=,}"); break; + case X86_INS_CWD: + esilprintf (op, "0,dx,=,15,ax,>>,?{,0xffff,dx,=,}"); + break; case X86_INS_CDQ: esilprintf (op, "0,edx,=,31,eax,>>,?{,0xffffffff,edx,=,}"); break; + case X86_INS_CQO: + esilprintf (op, "0,rdx,=,63,rax,>>,?{,-1,rdx,=,}"); + break; case X86_INS_CDQE: esilprintf (op, "eax,rax,=,31,rax,>>,?{,0xffffffff00000000,rax,|=,}"); break; From eccee9beb7d4242b6e17d6918fdd37a21eb5ac18 Mon Sep 17 00:00:00 2001 From: Dennis Goodlett Date: Fri, 18 Feb 2022 06:31:32 -0500 Subject: [PATCH 031/390] Add agfm command to print cfg graphs using mermaid syntax ##analysis --- libr/core/cmd_anal.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ test/db/cmd/cmd_agf | 47 +++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/libr/core/cmd_anal.c b/libr/core/cmd_anal.c index 3ef46e8752cfe..e847076660102 100644 --- a/libr/core/cmd_anal.c +++ b/libr/core/cmd_anal.c @@ -9703,6 +9703,62 @@ R_API void cmd_agfb2(RCore *core, const char *s) { free (pix); } +static bool cmd_graph_mermaid(RCore *core) { + RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, core->offset, 0); + if (!fcn || !fcn->bbs) { + return false; + } + + bool ret = true; + + // for info on mermaid syntax: https://mermaid-js.github.io/mermaid/#/stateDiagram + RStrBuf *nodes = r_strbuf_new ("stateDiagram-v2\n"); + RStrBuf *edges = r_strbuf_new (""); + + // TODO: add themeing to nodes buff here -> https://mermaid-js.github.io/mermaid/#/theming + + RAnalBlock *b; + RListIter *iter; + + r_list_sort (fcn->bbs, bb_cmp); + r_list_foreach (fcn->bbs, iter, b) { + // node names start with _0x b/c 0x makes mermaids mad somehow + if (b->addr != fcn->addr) { + ret &= r_strbuf_appendf (nodes, "\tstate \"0x%" PFMT64x "\" as _0x%" PFMT64x "\n", b->addr, b->addr); + } else { + ret &= r_strbuf_appendf (nodes, "\tstate \"ENTRY: 0x%" PFMT64x "\" as _0x%" PFMT64x "\n", b->addr, b->addr); + } + // TODO: make body contain assembly, this needs to be done with some care so characters are not misinterpreted + if (b->jump != UT64_MAX) { + if (b->fail != UT64_MAX) { + ret &= r_strbuf_appendf (edges, "\t_0x%" PFMT64x " --> _0x%" PFMT64x ": true\n", b->addr, b->jump); + ret &= r_strbuf_appendf (edges, "\t_0x%" PFMT64x " --> _0x%" PFMT64x ": false\n", b->addr, b->fail); + } else { + ret &= r_strbuf_appendf (edges, "\t_0x%" PFMT64x " --> _0x%" PFMT64x "\n", b->addr, b->jump); + } + } else if (b->fail != UT64_MAX) { + ret &= r_strbuf_appendf (edges, "\t_0x%" PFMT64x " --> _0x%" PFMT64x "\n", b->addr, b->fail); + } + if (!ret) { + break; + } + } + + if (ret) { + char *n = r_strbuf_drain_nofree (nodes); + char *e = r_strbuf_drain_nofree (edges); + if (n && e) { + r_cons_print (n); + r_cons_print (e); + } + free (n); + free (e); + } + r_strbuf_free (nodes); + r_strbuf_free (edges); + return ret; +} + static void cmd_anal_graph(RCore *core, const char *input) { core->graph->show_node_titles = r_config_get_i (core->config, "graph.ntitles"); r_cons_enable_highlight (false); @@ -9715,6 +9771,9 @@ static void cmd_anal_graph(RCore *core, const char *input) { case 'b': // "agfb" // braile cmd_agfb (core); break; + case 'm': /// "agfm" // mermaid + cmd_graph_mermaid (core); + break; case ' ': { // "agf " RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, core->offset, 0); r_core_visual_graph (core, NULL, fcn, false); diff --git a/test/db/cmd/cmd_agf b/test/db/cmd/cmd_agf index 14796941a03be..3aeb4ea01c10d 100644 --- a/test/db/cmd/cmd_agf +++ b/test/db/cmd/cmd_agf @@ -61,3 +61,50 @@ digraph code { } EOF RUN + +NAME=agfm basic mermaid output +FILE=bins/elf/ls +CMDS=< _0x15db5: true + _0x15cc0 --> _0x15d06: false + _0x15d06 --> _0x15db5: true + _0x15d06 --> _0x15d12: false + _0x15d12 --> _0x15db5: true + _0x15d12 --> _0x15d29: false + _0x15d29 --> _0x15d7e: true + _0x15d29 --> _0x15d67: false + _0x15d67 --> _0x15da0: true + _0x15d67 --> _0x15d7e: false + _0x15da0 --> _0x15d7e + _0x15db5 --> _0x15df6: true + _0x15db5 --> _0x15dc9: false + _0x15dc9 --> _0x15dd0 + _0x15dd0 --> _0x15dda: true + _0x15dd0 --> _0x15dd5: false + _0x15dd5 --> _0x15df0: true + _0x15dd5 --> _0x15dda: false + _0x15dda --> _0x15dd0: true + _0x15dda --> _0x15de3: false +EOF +RUN From b550b267a32edc974c92a00dfa0d6bb3febb99ad Mon Sep 17 00:00:00 2001 From: pancake Date: Fri, 18 Feb 2022 12:38:46 +0100 Subject: [PATCH 032/390] Fix slow loading times for small ELF sample ##bin --- libr/bin/format/elf/elf.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/libr/bin/format/elf/elf.c b/libr/bin/format/elf/elf.c index ed5cec5345054..00f8efc56b8ce 100644 --- a/libr/bin/format/elf/elf.c +++ b/libr/bin/format/elf/elf.c @@ -956,7 +956,6 @@ static Sdb *store_versioninfo_gnu_verdef(ELFOBJ *bin, Elf_(Shdr) *shdr, int sz) const char *link_section_name = ""; char *end = NULL; ut8 dfs[sizeof (Elf_(Verdef))] = { 0 }; - Sdb *sdb; ut32 cnt; size_t i; if (shdr->sh_link >= bin->ehdr.e_shnum) { @@ -984,8 +983,22 @@ static Sdb *store_versioninfo_gnu_verdef(ELFOBJ *bin, Elf_(Shdr) *shdr, int sz) if (link_shdr && bin->shstrtab && link_shdr->sh_name < bin->shstrtab_size) { link_section_name = &bin->shstrtab[link_shdr->sh_name]; } - sdb = sdb_new0 (); - end = (char *)defs + shdr->sh_size; + Sdb *sdb = sdb_new0 (); + if (!sdb) { + return false; + } + size_t shsize = shdr->sh_size; + if (shdr->sh_size > bin->size) { + if (bin->verbose) { + eprintf ("Truncating shsize from %d to %d\n", (int)shdr->sh_size, (int)bin->size); + } + if (bin->size > shdr->sh_offset) { + shsize = bin->size - shdr->sh_offset; + } else { + shsize = bin->size; + } + } + end = (char *)defs + shsize; //& shdr->sh_size; sdb_set (sdb, "section_name", section_name, 0); sdb_num_set (sdb, "entries", shdr->sh_info, 0); sdb_num_set (sdb, "addr", shdr->sh_addr, 0); From 14d071dea3e101483b235bb78469a5de127144dd Mon Sep 17 00:00:00 2001 From: Pau Rodriguez-Estivill Date: Wed, 16 Feb 2022 17:26:20 +0100 Subject: [PATCH 033/390] Move download artifacts as script --- .github/workflows/release.yml | 15 +++----------- .gitignore | 2 ++ sys/download-artifacts.sh | 39 +++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 12 deletions(-) create mode 100755 sys/download-artifacts.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c18f8610062a..4813f514bfca8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,18 +16,9 @@ jobs: run: ./sys/release-notes.sh | tee ./RELEASE_NOTES.md - name: Download artifacts env: - REPO: ${{ github.repository }} - COMMIT: ${{ github.sha }} - DESTDIR: dist/artifacts - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - RUN_ID=`gh run --repo "${REPO}" list --workflow "ci.yml" --json "databaseId,status,headSha" --jq '.[] | select(.status=="completed" and .headSha=="'"${COMMIT}"'") | .databaseId'` - gh run --repo "${REPO}" download "${RUN_ID}" --dir "${DESTDIR}" - RUN_ID=`gh run --repo "${REPO}" list --workflow "windows.yml" --json "databaseId,status,headSha" --jq '.[] | select(.status=="completed" and .headSha=="'"${COMMIT}"'") | .databaseId'` - gh run --repo "${REPO}" download "${RUN_ID}" --dir "${DESTDIR}" - RUN_ID=`gh run --repo "${REPO}" list --workflow "freebsd.yml" --json "databaseId,status,headSha" --jq '.[] | select(.status=="completed" and .headSha=="'"${COMMIT}"'") | .databaseId'` - gh run --repo "${REPO}" download "${RUN_ID}" --dir "${DESTDIR}" - find "${DESTDIR}" -type f + GH_REPO: ${{ github.repository }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./sys/download-artifacts.sh ${{ github.sha }} - name: Create GitHub release id: create_release uses: actions/create-release@v1 diff --git a/.gitignore b/.gitignore index cc9f73342ed6c..32636268bad86 100644 --- a/.gitignore +++ b/.gitignore @@ -139,3 +139,5 @@ libr/include/sdb **/d/*.gperf **/d/*.out **/d/*.inc +# Artifacts +/dist/artifacts \ No newline at end of file diff --git a/sys/download-artifacts.sh b/sys/download-artifacts.sh new file mode 100755 index 0000000000000..921353a6efede --- /dev/null +++ b/sys/download-artifacts.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +set -e + +WORKFLOWS="ci.yml windows.yml freebsd.yml" +DESTDIR="dist/artifacts" +LIMIT=100 + +if ! command -v gh &> /dev/null; then + echo "GitHub CLI (gh command) could not be found" + exit 1 +fi + +cd `dirname $PWD/$0`/.. + +COMMIT="$1" # Optional +if [ -z "${COMMIT}" ]; then + COMMIT=`git rev-parse HEAD` + echo "Detected commit: ${COMMIT}" +fi + +echo "Removing old dist artifacts..." +rm -Rf "${DESTDIR}" + +for WORKFLOW in $WORKFLOWS; do + echo "Looking for ${COMMIT} in ${WORKFLOW} last ${LIMIT} executions..." + RUN_ID=`gh run list --workflow "${WORKFLOW}" --limit "${LIMIT}" --json "databaseId,status,headSha" --jq '.[] | select(.status=="completed" and .headSha=="'"${COMMIT}"'") | .databaseId'` + if [ -n "${RUN_ID}" ]; then + echo "Found run id ${RUN_ID} for ${WORKFLOW} workflow." + echo "Downloading all artifacts..." + gh run download "${RUN_ID}" --dir "${DESTDIR}" + else + echo "No execution found for ${COMMIT} in the last ${LIMIT} executions of ${WORKFLOW} workflow." + exit 1 + fi +done + +echo "Artifacts downloaded:" +find "${DESTDIR}" -type f \ No newline at end of file From 807e92de29ea2648214e146d3ef66a686dc1f23b Mon Sep 17 00:00:00 2001 From: Pau Rodriguez-Estivill Date: Wed, 16 Feb 2022 17:49:36 +0100 Subject: [PATCH 034/390] Rename CI artifacts to job names --- .github/workflows/ci.yml | 67 +++++++++-------------------------- .github/workflows/freebsd.yml | 1 + .github/workflows/release.yml | 32 ++++++++--------- .github/workflows/windows.yml | 30 ++++++++-------- 4 files changed, 48 insertions(+), 82 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8fc253d5932d8..c461697af9839 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,12 +58,9 @@ jobs: - name: Installing with symlinks run: | sys/wasi.sh - - name: Extract r2 version - run: echo "##[set-output name=branch;]$( cd sys;python version.py )" - id: r2v - uses: actions/upload-artifact@v2 with: - name: radare2-${{ steps.r2v.outputs.branch }}-wasi.zip + name: build-wasi path: radare2-*-wasi.zip build-acr-gperf: name: linux-acr-gperf @@ -200,13 +197,10 @@ jobs: # NOLTO=1 sys/static.sh make -C binr/blob tar cJvf r2-static.tar.xz r2-static - - name: Extract r2 version - run: echo "##[set-output name=branch;]$( cd sys;python version.py )" - id: r2v - name: Pub uses: actions/upload-artifact@v2 with: - name: radare2-${{ steps.r2v.outputs.branch }}-static.tar.xz + name: linux-static path: r2-static.tar.xz - name: Static r2 build with meson run: | @@ -222,13 +216,10 @@ jobs: uses: actions/checkout@v2 - name: Packaging for Debian run: sys/debian.sh - - name: Extract r2 version - run: echo "##[set-output name=branch;]$( cd sys; python version.py )" - id: r2v - name: Pub uses: actions/upload-artifact@v2 with: - name: radare2_${{ steps.r2v.outputs.branch }}-debian_amd64.zip + name: linux-acr-deb-64 path: dist/debian/*/*.deb linux-acr-deb-32: runs-on: ubuntu-18.04 @@ -242,13 +233,10 @@ jobs: export LDFLAGS=-m32 export ARCH=i386 sys/debian.sh - - name: Extract r2 version - run: echo "##[set-output name=branch;]$( cd sys;python version.py )" - id: r2v - name: Pub uses: actions/upload-artifact@v2 with: - name: radare2_${{ steps.r2v.outputs.branch }}-debian_i386.zip + name: linux-acr-deb-32 path: dist/debian/*/*.deb ## RPM PACKAGES DISABLED # linux-meson-rpm: @@ -267,6 +255,7 @@ jobs: # - name: Pub # uses: actions/upload-artifact@v2 # with: +# name: linux-meson-rpm # path: RPMS/*/*.rpm *.rpm dist/rpm/*.rpm # centos-meson-rpm: # runs-on: ubuntu:18.04 @@ -295,6 +284,7 @@ jobs: # - name: Pub # uses: actions/upload-artifact@v2 # with: +# name: centos-meson-rpm # path: rpmbuild/RPMS/*/*.rpm linux-asan-fuzz: runs-on: ubuntu-20.04 @@ -346,9 +336,6 @@ jobs: uses: actions/checkout@v2 - name: Packaging run: dist/macos/build-pkg.sh - - name: Extract r2 version - run: echo "##[set-output name=branch;]$( python sys/version.py )" - id: r2v # - name: Building Radare2 # run: | # export CFLAGS="-O2" # -Werror -Wno-unused-result -Wno-unicode -Wno-unneeded-internal-declaration" @@ -357,7 +344,7 @@ jobs: uses: actions/upload-artifact@v2 with: path: dist/macos/*.pkg - name: radare2-${{ steps.r2v.outputs.branch }}_macos.pkg + name: macos-acr # macos-acr-m1: # runs-on: macos-latest # steps: @@ -365,14 +352,11 @@ jobs: # uses: actions/checkout@v2 # - name: Packaging # run: export CC="xcrun --sdk macosx11.1 gcc -arch arm64" ; dist/macos/build-pkg.sh -# - name: Extract r2 version -# run: echo "##[set-output name=branch;]$( python sys/version.py )" -# id: r2v # - name: Pub # uses: actions/upload-artifact@v2 # with: # path: dist/macos/*.pkg -# name: radare2-${{ steps.r2v.outputs.branch }}_macos_m1.pkg +# name: macos-acr-m1 macos-test: runs-on: macos-latest if: contains(github.ref, 'master') || contains(github.ref, 'ci-') @@ -398,15 +382,12 @@ jobs: run: brew install pkg-config ldid - name: Create cydia32 package run: ./sys/ios-cydia32.sh - - name: Extract r2 version - run: echo "##[set-output name=branch;]$( python sys/version.py )" - id: r2v - name: List sys/cydia run: ls -lahR ./dist/cydia - uses: actions/upload-artifact@v2 with: - name: radare2-arm32_${{ steps.r2v.outputs.branch }}_iphoneos-arm - path: ./dist/cydia/radare2/radare2-arm32_${{ steps.r2v.outputs.branch }}_iphoneos-arm.deb + name: ios-cydia32 + path: ./dist/cydia/radare2/radare2-arm32_*_iphoneos-arm.deb ios-cydia: if: contains(github.ref, 'master') || contains(github.ref, 'ci-') runs-on: macos-latest @@ -423,17 +404,12 @@ jobs: zip -r /tmp/r2ios-sdk.zip * popd mv /tmp/r2ios-sdk.zip . - - name: Extract r2 version - run: echo "##[set-output name=branch;]$( python sys/version.py )" - id: r2v - uses: actions/upload-artifact@v2 with: - name: r2ios_sdk-${{ steps.r2v.outputs.branch }}.zip - path: ./r2ios-sdk.zip - - uses: actions/upload-artifact@v2 - with: - name: radare2-${{ steps.r2v.outputs.branch }}_iphoneos-arm64.zip - path: ./dist/cydia/radare2*/*.deb + name: ios-cydia + path: | + ./r2ios-sdk.zip + ./dist/cydia/radare2*/*.deb android-acr-aarch64: if: contains(github.ref, 'master') || contains(github.ref, 'ci-') @@ -449,12 +425,9 @@ jobs: sys/android-ndk-install.sh sys/android-build.sh arm64 ls -l - - name: Extract r2 version - run: echo "##[set-output name=branch;]$( cd sys;python version.py )" - id: r2v - uses: actions/upload-artifact@v2 with: - name: radare2-${{ steps.r2v.outputs.branch }}-android-aarch64.tar.gz + name: android-acr-aarch64 path: radare2*android*aarch64.tar.gz android-acr-arm: @@ -471,12 +444,9 @@ jobs: sys/android-ndk-install.sh 16 arm sys/android-build.sh arm ls -l - - name: Extract r2 version - run: echo "##[set-output name=branch;]$( cd sys;python version.py )" - id: r2v - uses: actions/upload-artifact@v2 with: - name: radare2-${{ steps.r2v.outputs.branch }}-android-arm.tar.gz + name: android-acr-arm path: radare2*android*arm.tar.gz android-meson: @@ -501,10 +471,7 @@ jobs: cd /tmp rm -rf android-dir/include android-dir/lib tar --transform 's/android-dir/data\/data\/org.radareorg.radare2installer/g' -cvf radare2-android-${{ matrix.name }}.tar.gz android-dir/ - - name: Extract r2 version - run: echo "##[set-output name=branch;]$( cd sys;python version.py )" - id: r2v - uses: actions/upload-artifact@v2 with: - name: radare2-${{ steps.r2v.outputs.branch }}-android-${{ matrix.name }}.tar.gz + name: android-meson path: /tmp/radare2-android-${{ matrix.name }}.tar.gz diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index 1fd68f7ac1b34..e67f8a5eae3b5 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -35,4 +35,5 @@ jobs: echo DATE: ; date - uses: actions/upload-artifact@v2 with: + name: freebsd path: radare2-freebsd.tgz diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4813f514bfca8..419d86adf5170 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,7 +36,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/radare2_${{ steps.r2v.outputs.branch }}-debian_amd64.zip/radare2/radare2_${{ steps.r2v.outputs.branch }}_amd64.deb + asset_path: dist/artifacts/linux-acr-deb-64/radare2/radare2_${{ steps.r2v.outputs.branch }}_amd64.deb asset_name: radare2_${{ steps.r2v.outputs.branch }}_amd64.deb asset_content_type: application/vnd.debian.binary-package - name: Upload asset for Debian (i386) @@ -45,7 +45,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/radare2_${{ steps.r2v.outputs.branch }}-debian_i386.zip/radare2/radare2_${{ steps.r2v.outputs.branch }}_i386.deb + asset_path: dist/artifacts/linux-acr-deb-32/radare2/radare2_${{ steps.r2v.outputs.branch }}_i386.deb asset_name: radare2_${{ steps.r2v.outputs.branch }}_i386.deb asset_content_type: application/vnd.debian.binary-package - name: Upload asset for Windows (w64) @@ -54,7 +54,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/artifact/radare2-${{ steps.r2v.outputs.branch }}-w64.zip + asset_path: dist/artifacts/w64-meson/radare2-${{ steps.r2v.outputs.branch }}-w64.zip asset_name: radare2-${{ steps.r2v.outputs.branch }}-w64.zip asset_content_type: application/zip - name: Upload asset for Windows (w32) @@ -63,7 +63,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}-w32.zip/radare2-${{ steps.r2v.outputs.branch }}-w32.zip + asset_path: dist/artifacts/w32-meson/radare2-${{ steps.r2v.outputs.branch }}-w32.zip asset_name: radare2-${{ steps.r2v.outputs.branch }}-w32.zip asset_content_type: application/zip - name: Upload asset for macOS @@ -72,7 +72,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}_macos.pkg/radare2-${{ steps.r2v.outputs.branch }}.pkg + asset_path: dist/artifacts/macos-acr/radare2-${{ steps.r2v.outputs.branch }}.pkg asset_name: radare2-${{ steps.r2v.outputs.branch }}.pkg asset_content_type: application/x-xar - name: Upload asset for iPhoneOS (arm) @@ -81,7 +81,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}_iphoneos-arm64.zip/radare2/radare2_${{ steps.r2v.outputs.branch }}_iphoneos-arm.deb + asset_path: dist/artifacts/ios-cydia/dist/cydia/radare2/radare2_${{ steps.r2v.outputs.branch }}_iphoneos-arm.deb asset_name: radare2_${{ steps.r2v.outputs.branch }}_iphoneos-arm.deb asset_content_type: application/vnd.debian.binary-package - name: Upload asset for iPhoneOS (arm32) @@ -90,7 +90,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/radare2-arm32_${{ steps.r2v.outputs.branch }}_iphoneos-arm/radare2-arm32_${{ steps.r2v.outputs.branch }}_iphoneos-arm.deb + asset_path: dist/artifacts/ios-cydia32/radare2-arm32_${{ steps.r2v.outputs.branch }}_iphoneos-arm.deb asset_name: radare2-arm32_${{ steps.r2v.outputs.branch }}_iphoneos-arm.deb asset_content_type: application/vnd.debian.binary-package - name: Upload asset for iOS SDK @@ -99,7 +99,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/r2ios_sdk-${{ steps.r2v.outputs.branch }}.zip/r2ios-sdk.zip + asset_path: dist/artifacts/ios-cydia/r2ios-sdk.zip asset_name: r2ios-sdk-${{ steps.r2v.outputs.branch }}.zip asset_content_type: application/zip - name: Upload asset for Android (arm) @@ -108,7 +108,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}-android-arm.tar.gz/radare2-${{ steps.r2v.outputs.branch }}-android-arm.tar.gz + asset_path: dist/artifacts/android-acr-arm/radare2-${{ steps.r2v.outputs.branch }}-android-arm.tar.gz asset_name: radare2-${{ steps.r2v.outputs.branch }}-android-arm.tar.gz asset_content_type: application/gzip - name: Upload asset for Android (x86_64) @@ -117,7 +117,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}-android-x86_64.tar.gz/radare2-android-x86_64.tar.gz + asset_path: dist/artifacts/android-meson/radare2-android-x86_64.tar.gz asset_name: radare2-${{ steps.r2v.outputs.branch }}-android-x86_64.tar.gz asset_content_type: application/x-tar - name: Upload asset for Android (aarch64) @@ -126,7 +126,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}-android-aarch64.tar.gz/radare2-${{ steps.r2v.outputs.branch }}-android-aarch64.tar.gz + asset_path: dist/artifacts/android-acr-aarch64/radare2-${{ steps.r2v.outputs.branch }}-android-aarch64.tar.gz asset_name: radare2-${{ steps.r2v.outputs.branch }}-android-aarch64.tar.gz asset_content_type: application/gzip - name: Upload asset for Linux (static) @@ -135,7 +135,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}-static.tar.xz/r2-static.tar.xz + asset_path: dist/artifacts/linux-static/r2-static.tar.xz asset_name: radare2-${{ steps.r2v.outputs.branch }}-static.tar.xz asset_content_type: application/x-xz - name: Upload asset for Debian dev (amd64) @@ -144,7 +144,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/radare2_${{ steps.r2v.outputs.branch }}-debian_amd64.zip/radare2-dev/radare2-dev_${{ steps.r2v.outputs.branch }}_amd64.deb + asset_path: dist/artifacts/linux-acr-deb-64/radare2-dev/radare2-dev_${{ steps.r2v.outputs.branch }}_amd64.deb asset_name: radare2-dev_${{ steps.r2v.outputs.branch }}_amd64.deb asset_content_type: application/vnd.debian.binary-package - name: Upload asset for Debian dev (i386) @@ -153,7 +153,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/radare2_${{ steps.r2v.outputs.branch }}-debian_i386.zip/radare2-dev/radare2-dev_${{ steps.r2v.outputs.branch }}_i386.deb + asset_path: dist/artifacts/linux-acr-deb-32/radare2-dev/radare2-dev_${{ steps.r2v.outputs.branch }}_i386.deb asset_name: radare2-dev_${{ steps.r2v.outputs.branch }}_i386.deb asset_content_type: application/vnd.debian.binary-package - name: Upload asset for WASI @@ -162,7 +162,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/radare2-${{ steps.r2v.outputs.branch }}-wasi.zip/radare2-${{ steps.r2v.outputs.branch }}-wasi.zip + asset_path: dist/artifacts/build-wasi/radare2-${{ steps.r2v.outputs.branch }}-wasi.zip asset_name: radare2-${{ steps.r2v.outputs.branch }}-wasi.zip asset_content_type: application/zip - name: Upload asset for FreeBSD @@ -171,6 +171,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/artifact/radare2-freebsd.tgz + asset_path: dist/artifacts/freebsd/radare2-freebsd.tgz asset_name: radare2-${{ steps.r2v.outputs.branch }}-freebsd.tgz asset_content_type: application/gzip diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 5062057ee1490..a2ed60a24484d 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -21,6 +21,7 @@ jobs: sys/mingw32.sh - uses: actions/upload-artifact@v2 with: + name: w32-mingw path: radare2*.zip w64-mingw: name: w64-mingw @@ -35,6 +36,7 @@ jobs: sys/mingw64.sh - uses: actions/upload-artifact@v2 with: + name: w64-mingw path: radare2*.zip w64-make: runs-on: windows-2019 @@ -105,10 +107,6 @@ jobs: ninja -C build -j1 install - name: Create zip artifact run: 7z a radare2-${{ steps.r2v.outputs.branch }}-w32.zip $PWD\radare2-${{ steps.r2v.outputs.branch }}-w32 - - uses: actions/upload-artifact@v2 - with: - name: radare2-${{ steps.r2v.outputs.branch }}-w32.zip - path: radare2-${{ steps.r2v.outputs.branch }}-w32.zip # - uses: actions/checkout@v2 # with: # repository: radareorg/radare2-win-installer @@ -119,10 +117,12 @@ jobs: # - name: Create installer # shell: pwsh # run: iscc radare2-win-installer\radare2.iss /DRadare2Location=..\radare2-install\* /DLicenseLocation=..\COPYING.LESSER /DIcoLocation=radare2.ico /DMyAppVersion=${{ steps.extract_version.outputs.branch }} -# - uses: actions/upload-artifact@v2 -# with: -# name: radare2-w32-installer-git.exe -# path: radare2-win-installer\Output\radare2.exe + - uses: actions/upload-artifact@v2 + with: + name: w32-meson + path: | + radare2-${{ steps.r2v.outputs.branch }}-w32.zip +# radare2-win-installer\Output\radare2.exe w64-meson: runs-on: windows-2019 steps: @@ -160,10 +160,6 @@ jobs: ninja -C build install - name: Create zip artifact run: 7z a radare2-${{ steps.r2v.outputs.branch }}-w64.zip $PWD\radare2-${{ steps.r2v.outputs.branch }}-w64 - - uses: actions/upload-artifact@v2 - with: - name: radare2-${{ steps.r2v.outputs.branch }}-w64.zip - path: radare2-${{ steps.r2v.outputs.branch }}-w64.zip # - uses: actions/checkout@v2 # with: # repository: radareorg/radare2-win-installer @@ -171,8 +167,10 @@ jobs: # - name: Create installer # shell: pwsh # run: iscc radare2-win-installer\radare2.iss /DRadare2Location=..\radare2-install\* /DLicenseLocation=..\COPYING.LESSER /DIcoLocation=radare2.ico /DMyAppVersion=${{ steps.extract_version.outputs.branch }} -# - uses: actions/upload-artifact@v2 -# with: -# name: radare2-w64-installer-git.zip -# path: radare2-win-installer\Output\radare2.exe + - uses: actions/upload-artifact@v2 + with: + name: w64-meson + path: | + radare2-${{ steps.r2v.outputs.branch }}-w64.zip +# radare2-win-installer\Output\radare2.exe # LINUX From 041acbb2caa1b7b565c3fe4441997c075386011c Mon Sep 17 00:00:00 2001 From: Pau Rodriguez-Estivill Date: Wed, 16 Feb 2022 20:22:03 +0100 Subject: [PATCH 035/390] Split CI workflows --- .github/workflows/android.yml | 73 ++++++++++ .github/workflows/apple.yml | 77 +++++++++++ .github/workflows/ci.yml | 253 ---------------------------------- .github/workflows/linux.yml | 126 +++++++++++++++++ .github/workflows/release.yml | 2 +- sys/download-artifacts.sh | 2 +- 6 files changed, 278 insertions(+), 255 deletions(-) create mode 100644 .github/workflows/android.yml create mode 100644 .github/workflows/apple.yml create mode 100644 .github/workflows/linux.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 0000000000000..f8f445e063072 --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,73 @@ +name: android + +on: + push: + branches: + - master + pull_request: + +jobs: + android-acr-aarch64: + if: contains(github.ref, 'master') || contains(github.ref, 'ci-') + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: sudo apt-get --assume-yes install pax wget gperf cabextract unzip python3-wheel python3-setuptools python3-pip && pip3 install --user meson ninja + - name: Compile with acr + run: | + sys/android-ndk-install.sh + sys/android-build.sh arm64 + ls -l + - uses: actions/upload-artifact@v2 + with: + name: android-acr-aarch64 + path: radare2*android*aarch64.tar.gz + + android-acr-arm: + if: contains(github.ref, 'master') || contains(github.ref, 'ci-') + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: sudo apt-get --assume-yes install pax wget gperf cabextract unzip python3-wheel python3-setuptools python3-pip && pip3 install --user meson ninja + - name: Compile with acr + run: | + sys/android-ndk-install.sh 16 arm + sys/android-build.sh arm + ls -l + - uses: actions/upload-artifact@v2 + with: + name: android-acr-arm + path: radare2*android*arm.tar.gz + + android-meson: + if: contains(github.ref, 'master') || contains(github.ref, 'ci-') + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + # name: [x86_64, arm, aarch64] + name: [x86_64] + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: sudo apt-get --assume-yes install pax wget cabextract unzip python3-wheel python3-setuptools python3-pip && pip3 install --user meson ninja + - name: Compile with meson + run: | + export PATH=${HOME}/.local/bin:${PATH} + CFLAGS="-static" LDFLAGS="-static" meson --buildtype release --default-library static --prefix=/tmp/android-dir -Dblob=true build --cross-file .github/meson-android-${{ matrix.name }}.ini + ninja -C build && ninja -C build install + - name: Create radare2-android-${{ matrix.name }}.tar.gz + run: | + cd /tmp + rm -rf android-dir/include android-dir/lib + tar --transform 's/android-dir/data\/data\/org.radareorg.radare2installer/g' -cvf radare2-android-${{ matrix.name }}.tar.gz android-dir/ + - uses: actions/upload-artifact@v2 + with: + name: android-meson + path: /tmp/radare2-android-${{ matrix.name }}.tar.gz diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml new file mode 100644 index 0000000000000..96fc73b89dd42 --- /dev/null +++ b/.github/workflows/apple.yml @@ -0,0 +1,77 @@ +name: apple + +on: + push: + branches: + - master + pull_request: + +jobs: + # macOS + macos-acr: + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Packaging + run: dist/macos/build-pkg.sh +# - name: Building Radare2 +# run: | +# export CFLAGS="-O2" # -Werror -Wno-unused-result -Wno-unicode -Wno-unneeded-internal-declaration" +# sys/install.sh && make -C dist/macos + - name: Pub + uses: actions/upload-artifact@v2 + with: + path: dist/macos/*.pkg + name: macos-acr +# macos-acr-m1: +# runs-on: macos-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v2 +# - name: Packaging +# run: export CC="xcrun --sdk macosx11.1 gcc -arch arm64" ; dist/macos/build-pkg.sh +# - name: Pub +# uses: actions/upload-artifact@v2 +# with: +# path: dist/macos/*.pkg +# name: macos-acr-m1 + + # Mobile + ios-cydia32: + if: contains(github.ref, 'master') || contains(github.ref, 'ci-') + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: Install pkg-config/ldid2 with Homebrew + run: brew install pkg-config ldid + - name: Create cydia32 package + run: ./sys/ios-cydia32.sh + - name: List sys/cydia + run: ls -lahR ./dist/cydia + - uses: actions/upload-artifact@v2 + with: + name: ios-cydia32 + path: ./dist/cydia/radare2/radare2-arm32_*_iphoneos-arm.deb + ios-cydia: + if: contains(github.ref, 'master') || contains(github.ref, 'ci-') + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: Install pkg-config/ldid2 with Homebrew + run: brew install pkg-config ldid + - name: Create cydia package + run: ./sys/ios-cydia.sh + - name: Create iOS SDK + run: | + ./sys/ios-sdk.sh + pushd /tmp/r2ios + zip -r /tmp/r2ios-sdk.zip * + popd + mv /tmp/r2ios-sdk.zip . + - uses: actions/upload-artifact@v2 + with: + name: ios-cydia + path: | + ./r2ios-sdk.zip + ./dist/cydia/radare2*/*.deb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c461697af9839..f1c5d6ac2d023 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,6 @@ on: # schedule: # - cron: '0 0 * * 1' - jobs: build-offline: name: linux-offline @@ -49,19 +48,6 @@ jobs: run: | cp -f dist/plugins-cfg/plugins.nocs.cfg plugins.cfg ./configure --without-capstone && make -j - build-wasi: - name: linux-wasi - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Installing with symlinks - run: | - sys/wasi.sh - - uses: actions/upload-artifact@v2 - with: - name: build-wasi - path: radare2-*-wasi.zip build-acr-gperf: name: linux-acr-gperf runs-on: ubuntu-20.04 @@ -181,111 +167,6 @@ jobs: cd .. find "/tmp/r 2" LD_LIBRARY_PATH="/tmp/r 2/lib/x86_64-linux-gnu/" "/tmp/r 2/bin/r2" -v - linux-static: - if: contains(github.ref, 'master') || contains(github.ref, 'ci-') - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Installing the musl runtime - run: | - sudo apt install musl-tools - - name: Building static r2 with acr - run: | - cp -f dist/plugins-cfg/plugins.static.nogpl.cfg plugins.cfg - NOLTO=1 sys/static.sh - # NOLTO=1 sys/static.sh - make -C binr/blob - tar cJvf r2-static.tar.xz r2-static - - name: Pub - uses: actions/upload-artifact@v2 - with: - name: linux-static - path: r2-static.tar.xz - - name: Static r2 build with meson - run: | - sudo apt-get --assume-yes install python3-wheel python3-setuptools cabextract gperf - sudo pip3 install meson ninja - CFLAGS="-static" LDFLAGS="-static" meson --prefix=${HOME}/.local --buildtype release --default-library static build - ninja -C build && ninja -C build install - linux-acr-deb-64: - if: contains(github.ref, 'master') || contains(github.ref, 'ci-') - runs-on: ubuntu-18.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Packaging for Debian - run: sys/debian.sh - - name: Pub - uses: actions/upload-artifact@v2 - with: - name: linux-acr-deb-64 - path: dist/debian/*/*.deb - linux-acr-deb-32: - runs-on: ubuntu-18.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Packaging for 32bit Debian - run: | - sudo apt install gcc-multilib gperf - export CFLAGS=-m32 - export LDFLAGS=-m32 - export ARCH=i386 - sys/debian.sh - - name: Pub - uses: actions/upload-artifact@v2 - with: - name: linux-acr-deb-32 - path: dist/debian/*/*.deb -## RPM PACKAGES DISABLED -# linux-meson-rpm: -# runs-on: ubuntu:18.04 -# container: centos:8 -# steps: -# - name: Checkout -# uses: actions/checkout@v2 -# - name: Prepare Skeleton -# run: | -# mkdir -p SOURCES SPECS -# cp -f dist/rpm/*spec SPECS -# wget -O https://github.com/radareorg/radare2/archive/master/radare2-5.1.0-git.tar.gz -# - name: rpmbuild -# uses: robertdebock/rpmbuild-action@1.1.1 -# - name: Pub -# uses: actions/upload-artifact@v2 -# with: -# name: linux-meson-rpm -# path: RPMS/*/*.rpm *.rpm dist/rpm/*.rpm -# centos-meson-rpm: -# runs-on: ubuntu:18.04 -# container: centos:8 -# steps: -# - name: Checkout -# uses: actions/checkout@v2 -# - name: Install tools for CentOS:8 -# run: | -# yum install -y patch unzip git gcc make python38 python38-pip rpm-build rpmdevtools wget -# pip3.8 install meson ninja r2pipe -# - name: Building with Meson -# run: | -# meson build -# ninja -C build -# ninja -C build install -# - name: RPM Packaging -# run: | -# cp -f dist/rpm/radare2.spec . -# rpmdev-setuptree -# mkdir -p rpmbuild/SOURCES -# cd rpmbuild/SOURCES -# wget https://github.com/radareorg/radare2/archive/5860c3efc12d4b75e72bdce4b1d3834599620913/radare2-5.1.0-git.tar.gz -# cd - -# rpmbuild -ba radare2.spec -# - name: Pub -# uses: actions/upload-artifact@v2 -# with: -# name: centos-meson-rpm -# path: rpmbuild/RPMS/*/*.rpm linux-asan-fuzz: runs-on: ubuntu-20.04 continue-on-error: true @@ -327,36 +208,6 @@ jobs: run: | export LD_LIBRARY_PATH=/usr/local/lib make tests - - # Apple - macos-acr: - runs-on: macos-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Packaging - run: dist/macos/build-pkg.sh -# - name: Building Radare2 -# run: | -# export CFLAGS="-O2" # -Werror -Wno-unused-result -Wno-unicode -Wno-unneeded-internal-declaration" -# sys/install.sh && make -C dist/macos - - name: Pub - uses: actions/upload-artifact@v2 - with: - path: dist/macos/*.pkg - name: macos-acr -# macos-acr-m1: -# runs-on: macos-latest -# steps: -# - name: Checkout -# uses: actions/checkout@v2 -# - name: Packaging -# run: export CC="xcrun --sdk macosx11.1 gcc -arch arm64" ; dist/macos/build-pkg.sh -# - name: Pub -# uses: actions/upload-artifact@v2 -# with: -# path: dist/macos/*.pkg -# name: macos-acr-m1 macos-test: runs-on: macos-latest if: contains(github.ref, 'master') || contains(github.ref, 'ci-') @@ -371,107 +222,3 @@ jobs: run: export CFLAGS="-O2"; sys/install.sh - name: Running tests run: pip3 install r2pipe; make tests - - # Mobile - ios-cydia32: - if: contains(github.ref, 'master') || contains(github.ref, 'ci-') - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - name: Install pkg-config/ldid2 with Homebrew - run: brew install pkg-config ldid - - name: Create cydia32 package - run: ./sys/ios-cydia32.sh - - name: List sys/cydia - run: ls -lahR ./dist/cydia - - uses: actions/upload-artifact@v2 - with: - name: ios-cydia32 - path: ./dist/cydia/radare2/radare2-arm32_*_iphoneos-arm.deb - ios-cydia: - if: contains(github.ref, 'master') || contains(github.ref, 'ci-') - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - name: Install pkg-config/ldid2 with Homebrew - run: brew install pkg-config ldid - - name: Create cydia package - run: ./sys/ios-cydia.sh - - name: Create iOS SDK - run: | - ./sys/ios-sdk.sh - pushd /tmp/r2ios - zip -r /tmp/r2ios-sdk.zip * - popd - mv /tmp/r2ios-sdk.zip . - - uses: actions/upload-artifact@v2 - with: - name: ios-cydia - path: | - ./r2ios-sdk.zip - ./dist/cydia/radare2*/*.deb - - android-acr-aarch64: - if: contains(github.ref, 'master') || contains(github.ref, 'ci-') - runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - - uses: actions/checkout@v2 - - name: Install dependencies - run: sudo apt-get --assume-yes install pax wget gperf cabextract unzip python3-wheel python3-setuptools python3-pip && pip3 install --user meson ninja - - name: Compile with acr - run: | - sys/android-ndk-install.sh - sys/android-build.sh arm64 - ls -l - - uses: actions/upload-artifact@v2 - with: - name: android-acr-aarch64 - path: radare2*android*aarch64.tar.gz - - android-acr-arm: - if: contains(github.ref, 'master') || contains(github.ref, 'ci-') - runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - - uses: actions/checkout@v2 - - name: Install dependencies - run: sudo apt-get --assume-yes install pax wget gperf cabextract unzip python3-wheel python3-setuptools python3-pip && pip3 install --user meson ninja - - name: Compile with acr - run: | - sys/android-ndk-install.sh 16 arm - sys/android-build.sh arm - ls -l - - uses: actions/upload-artifact@v2 - with: - name: android-acr-arm - path: radare2*android*arm.tar.gz - - android-meson: - if: contains(github.ref, 'master') || contains(github.ref, 'ci-') - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - # name: [x86_64, arm, aarch64] - name: [x86_64] - steps: - - uses: actions/checkout@v2 - - name: Install dependencies - run: sudo apt-get --assume-yes install pax wget cabextract unzip python3-wheel python3-setuptools python3-pip && pip3 install --user meson ninja - - name: Compile with meson - run: | - export PATH=${HOME}/.local/bin:${PATH} - CFLAGS="-static" LDFLAGS="-static" meson --buildtype release --default-library static --prefix=/tmp/android-dir -Dblob=true build --cross-file .github/meson-android-${{ matrix.name }}.ini - ninja -C build && ninja -C build install - - name: Create radare2-android-${{ matrix.name }}.tar.gz - run: | - cd /tmp - rm -rf android-dir/include android-dir/lib - tar --transform 's/android-dir/data\/data\/org.radareorg.radare2installer/g' -cvf radare2-android-${{ matrix.name }}.tar.gz android-dir/ - - uses: actions/upload-artifact@v2 - with: - name: android-meson - path: /tmp/radare2-android-${{ matrix.name }}.tar.gz diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000000000..4f327a9afc3dc --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,126 @@ +name: linux + +on: + push: + branches: + - master + pull_request: + +jobs: + linux-wasi: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Installing with symlinks + run: | + sys/wasi.sh + - uses: actions/upload-artifact@v2 + with: + name: linux-wasi + path: radare2-*-wasi.zip + linux-static: + if: contains(github.ref, 'master') || contains(github.ref, 'ci-') + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Installing the musl runtime + run: | + sudo apt install musl-tools + - name: Building static r2 with acr + run: | + cp -f dist/plugins-cfg/plugins.static.nogpl.cfg plugins.cfg + NOLTO=1 sys/static.sh + # NOLTO=1 sys/static.sh + make -C binr/blob + tar cJvf r2-static.tar.xz r2-static + - name: Pub + uses: actions/upload-artifact@v2 + with: + name: linux-static + path: r2-static.tar.xz + - name: Static r2 build with meson + run: | + sudo apt-get --assume-yes install python3-wheel python3-setuptools cabextract gperf + sudo pip3 install meson ninja + CFLAGS="-static" LDFLAGS="-static" meson --prefix=${HOME}/.local --buildtype release --default-library static build + ninja -C build && ninja -C build install + linux-acr-deb-64: + if: contains(github.ref, 'master') || contains(github.ref, 'ci-') + runs-on: ubuntu-18.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Packaging for Debian + run: sys/debian.sh + - name: Pub + uses: actions/upload-artifact@v2 + with: + name: linux-acr-deb-64 + path: dist/debian/*/*.deb + linux-acr-deb-32: + runs-on: ubuntu-18.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Packaging for 32bit Debian + run: | + sudo apt install gcc-multilib gperf + export CFLAGS=-m32 + export LDFLAGS=-m32 + export ARCH=i386 + sys/debian.sh + - name: Pub + uses: actions/upload-artifact@v2 + with: + name: linux-acr-deb-32 + path: dist/debian/*/*.deb +## RPM PACKAGES DISABLED +# linux-meson-rpm: +# runs-on: ubuntu:18.04 +# container: centos:8 +# steps: +# - name: Checkout +# uses: actions/checkout@v2 +# - name: Prepare Skeleton +# run: | +# mkdir -p SOURCES SPECS +# cp -f dist/rpm/*spec SPECS +# wget -O https://github.com/radareorg/radare2/archive/master/radare2-5.1.0-git.tar.gz +# - name: rpmbuild +# uses: robertdebock/rpmbuild-action@1.1.1 +# - name: Pub +# uses: actions/upload-artifact@v2 +# with: +# name: linux-meson-rpm +# path: RPMS/*/*.rpm *.rpm dist/rpm/*.rpm +# centos-meson-rpm: +# runs-on: ubuntu:18.04 +# container: centos:8 +# steps: +# - name: Checkout +# uses: actions/checkout@v2 +# - name: Install tools for CentOS:8 +# run: | +# yum install -y patch unzip git gcc make python38 python38-pip rpm-build rpmdevtools wget +# pip3.8 install meson ninja r2pipe +# - name: Building with Meson +# run: | +# meson build +# ninja -C build +# ninja -C build install +# - name: RPM Packaging +# run: | +# cp -f dist/rpm/radare2.spec . +# rpmdev-setuptree +# mkdir -p rpmbuild/SOURCES +# cd rpmbuild/SOURCES +# wget https://github.com/radareorg/radare2/archive/5860c3efc12d4b75e72bdce4b1d3834599620913/radare2-5.1.0-git.tar.gz +# cd - +# rpmbuild -ba radare2.spec +# - name: Pub +# uses: actions/upload-artifact@v2 +# with: +# name: centos-meson-rpm +# path: rpmbuild/RPMS/*/*.rpm \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 419d86adf5170..c33fe602eb40d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -162,7 +162,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/artifacts/build-wasi/radare2-${{ steps.r2v.outputs.branch }}-wasi.zip + asset_path: dist/artifacts/linux-wasi/radare2-${{ steps.r2v.outputs.branch }}-wasi.zip asset_name: radare2-${{ steps.r2v.outputs.branch }}-wasi.zip asset_content_type: application/zip - name: Upload asset for FreeBSD diff --git a/sys/download-artifacts.sh b/sys/download-artifacts.sh index 921353a6efede..42c5f2d8e870b 100755 --- a/sys/download-artifacts.sh +++ b/sys/download-artifacts.sh @@ -2,7 +2,7 @@ set -e -WORKFLOWS="ci.yml windows.yml freebsd.yml" +WORKFLOWS="linux apple android windows freebsd" DESTDIR="dist/artifacts" LIMIT=100 From 108dc76ae8fe61e62bf7082c32bd47d7db496f78 Mon Sep 17 00:00:00 2001 From: Pau Rodriguez-Estivill Date: Thu, 17 Feb 2022 11:00:20 +0100 Subject: [PATCH 036/390] Setup artifacts retention time to 30 days --- .github/workflows/android.yml | 3 +++ .github/workflows/apple.yml | 4 ++++ .github/workflows/freebsd.yml | 1 + .github/workflows/linux.yml | 8 +++++++- .github/workflows/windows.yml | 5 ++++- 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index f8f445e063072..58089410fcad9 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -25,6 +25,7 @@ jobs: with: name: android-acr-aarch64 path: radare2*android*aarch64.tar.gz + retention-days: 30 android-acr-arm: if: contains(github.ref, 'master') || contains(github.ref, 'ci-') @@ -44,6 +45,7 @@ jobs: with: name: android-acr-arm path: radare2*android*arm.tar.gz + retention-days: 30 android-meson: if: contains(github.ref, 'master') || contains(github.ref, 'ci-') @@ -71,3 +73,4 @@ jobs: with: name: android-meson path: /tmp/radare2-android-${{ matrix.name }}.tar.gz + retention-days: 30 diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 96fc73b89dd42..c30ad91a3cb7f 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -24,6 +24,7 @@ jobs: with: path: dist/macos/*.pkg name: macos-acr + retention-days: 30 # macos-acr-m1: # runs-on: macos-latest # steps: @@ -36,6 +37,7 @@ jobs: # with: # path: dist/macos/*.pkg # name: macos-acr-m1 +# retention-days: 30 # Mobile ios-cydia32: @@ -53,6 +55,7 @@ jobs: with: name: ios-cydia32 path: ./dist/cydia/radare2/radare2-arm32_*_iphoneos-arm.deb + retention-days: 30 ios-cydia: if: contains(github.ref, 'master') || contains(github.ref, 'ci-') runs-on: macos-latest @@ -75,3 +78,4 @@ jobs: path: | ./r2ios-sdk.zip ./dist/cydia/radare2*/*.deb + retention-days: 30 diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index e67f8a5eae3b5..359d54c0ff5f1 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -37,3 +37,4 @@ jobs: with: name: freebsd path: radare2-freebsd.tgz + retention-days: 30 diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 4f327a9afc3dc..8bb41e4e67450 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -19,6 +19,7 @@ jobs: with: name: linux-wasi path: radare2-*-wasi.zip + retention-days: 30 linux-static: if: contains(github.ref, 'master') || contains(github.ref, 'ci-') runs-on: ubuntu-20.04 @@ -40,6 +41,7 @@ jobs: with: name: linux-static path: r2-static.tar.xz + retention-days: 30 - name: Static r2 build with meson run: | sudo apt-get --assume-yes install python3-wheel python3-setuptools cabextract gperf @@ -59,6 +61,7 @@ jobs: with: name: linux-acr-deb-64 path: dist/debian/*/*.deb + retention-days: 30 linux-acr-deb-32: runs-on: ubuntu-18.04 steps: @@ -76,6 +79,7 @@ jobs: with: name: linux-acr-deb-32 path: dist/debian/*/*.deb + retention-days: 30 ## RPM PACKAGES DISABLED # linux-meson-rpm: # runs-on: ubuntu:18.04 @@ -95,6 +99,7 @@ jobs: # with: # name: linux-meson-rpm # path: RPMS/*/*.rpm *.rpm dist/rpm/*.rpm +# retention-days: 30 # centos-meson-rpm: # runs-on: ubuntu:18.04 # container: centos:8 @@ -123,4 +128,5 @@ jobs: # uses: actions/upload-artifact@v2 # with: # name: centos-meson-rpm -# path: rpmbuild/RPMS/*/*.rpm \ No newline at end of file +# path: rpmbuild/RPMS/*/*.rpm +# retention-days: 30 \ No newline at end of file diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index a2ed60a24484d..a286c75f179d8 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -23,6 +23,7 @@ jobs: with: name: w32-mingw path: radare2*.zip + retention-days: 30 w64-mingw: name: w64-mingw runs-on: ubuntu-20.04 @@ -38,6 +39,7 @@ jobs: with: name: w64-mingw path: radare2*.zip + retention-days: 30 w64-make: runs-on: windows-2019 steps: @@ -123,6 +125,7 @@ jobs: path: | radare2-${{ steps.r2v.outputs.branch }}-w32.zip # radare2-win-installer\Output\radare2.exe + retention-days: 30 w64-meson: runs-on: windows-2019 steps: @@ -173,4 +176,4 @@ jobs: path: | radare2-${{ steps.r2v.outputs.branch }}-w64.zip # radare2-win-installer\Output\radare2.exe -# LINUX + retention-days: 30 From c84b7232626badd075caf3ae29661b609164bac6 Mon Sep 17 00:00:00 2001 From: pancake Date: Fri, 18 Feb 2022 00:58:43 +0100 Subject: [PATCH 037/390] Fix heap buffer overflow in dyldcache parser ##crash * Reported by: Lazymio via huntr.dev * Reproducer: dyldovf --- libr/bin/p/bin_dyldcache.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libr/bin/p/bin_dyldcache.c b/libr/bin/p/bin_dyldcache.c index d76699b72f79c..6b7b512b71365 100644 --- a/libr/bin/p/bin_dyldcache.c +++ b/libr/bin/p/bin_dyldcache.c @@ -1144,6 +1144,8 @@ static ut64 resolve_symbols_off(RDyldCache *cache, ut64 pa) { static RList *create_cache_bins(RBinFile *bf, RDyldCache *cache) { RList *bins = r_list_newf ((RListFree)free_bin); + ut16 *depArray = NULL; + cache_imgxtr_t *extras = NULL; if (!bins) { return NULL; } @@ -1177,8 +1179,6 @@ static RList *create_cache_bins(RBinFile *bf, RDyldCache *cache) { } ut32 j; - ut16 *depArray = NULL; - cache_imgxtr_t *extras = NULL; if (target_libs) { HtPU *path_to_idx = NULL; if (cache->accel) { @@ -1734,12 +1734,12 @@ static void populate_cache_maps(RDyldCache *cache) { cache->n_maps = next_map; } -static cache_accel_t *read_cache_accel(RBuffer *cache_buf, cache_hdr_t *hdr, cache_map_t *maps) { +static cache_accel_t *read_cache_accel(RBuffer *cache_buf, cache_hdr_t *hdr, cache_map_t *maps, int n_maps) { if (!cache_buf || !hdr || !hdr->accelerateInfoSize || !hdr->accelerateInfoAddr) { return NULL; } - - ut64 offset = va2pa (hdr->accelerateInfoAddr, hdr->mappingCount, maps, cache_buf, 0, NULL, NULL); + size_t mc = R_MIN (hdr->mappingCount, n_maps); + ut64 offset = va2pa (hdr->accelerateInfoAddr, mc, maps, cache_buf, 0, NULL, NULL); if (!offset) { return NULL; } @@ -1895,7 +1895,7 @@ static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *buf, ut64 loadadd r_dyldcache_free (cache); return false; } - cache->accel = read_cache_accel (cache->buf, cache->hdr, cache->maps); + cache->accel = read_cache_accel (cache->buf, cache->hdr, cache->maps, cache->n_maps); cache->bins = create_cache_bins (bf, cache); if (!cache->bins) { r_dyldcache_free (cache); From 5165f0c7bab0ef84a57d2439422ae5ec3de6bc67 Mon Sep 17 00:00:00 2001 From: Lazula <26179473+Lazula@users.noreply.github.com> Date: Fri, 18 Feb 2022 06:52:47 -0600 Subject: [PATCH 038/390] Free subprocess thread lock in r2r --- binr/r2r/run.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/binr/r2r/run.c b/binr/r2r/run.c index 0a359bbc3a0d4..7463726c621da 100644 --- a/binr/r2r/run.c +++ b/binr/r2r/run.c @@ -803,6 +803,8 @@ static R2RProcessOutput *subprocess_runner(const char *file, const char *args[], if (out) { out->timeout = timeout; } + r_th_lock_leave (proc->lock); + r_th_lock_free (proc->lock); r2r_subprocess_free (proc); return out; } @@ -996,6 +998,7 @@ R_API bool r2r_check_jq_available(void) { r_th_lock_enter (proc->lock); bool invalid_detected = proc && proc->ret != 0; r_th_lock_leave (proc->lock); + r_th_lock_free (proc->lock); r2r_subprocess_free (proc); proc = NULL; @@ -1008,6 +1011,7 @@ R_API bool r2r_check_jq_available(void) { r_th_lock_enter (proc->lock); bool valid_detected = proc && proc->ret == 0; r_th_lock_leave (proc->lock); + r_th_lock_free (proc->lock); r2r_subprocess_free (proc); return invalid_detected && valid_detected; From 3de3c43ec65cc159a1583d8ece4893e21bb3a9ca Mon Sep 17 00:00:00 2001 From: Lazula <26179473+Lazula@users.noreply.github.com> Date: Fri, 18 Feb 2022 06:23:11 -0600 Subject: [PATCH 039/390] Free color in r_cons_pal_init() --- libr/cons/pal.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libr/cons/pal.c b/libr/cons/pal.c index ed757afe8e602..385ec9ce087d7 100644 --- a/libr/cons/pal.c +++ b/libr/cons/pal.c @@ -155,16 +155,17 @@ static void __cons_pal_update_event(RConsContext *ctx) { static R_TH_LOCAL RThreadLock *lock = NULL; R_API void r_cons_pal_init(RConsContext *ctx) { + size_t i; if (!lock) { lock = r_th_lock_new (false); } r_th_lock_enter (lock); memset (&ctx->cpal, 0, sizeof (ctx->cpal)); -// r_cons_pal_free (ctx); - size_t i; for (i = 0; keys[i].name; i++) { char **color = (char **) (((ut8 *) &(ctx->pal)) + keys[i].off); - *color = NULL; + if (color && *color) { + R_FREE (*color); + } } ctx->cpal.b0x00 = (RColor) RColor_GREEN; From 6e4819b0543947916c21a15050c3d11b0eef6ae1 Mon Sep 17 00:00:00 2001 From: pkubaj Date: Fri, 18 Feb 2022 18:25:53 +0000 Subject: [PATCH 040/390] Add support for powerpc, powerpc64, powerpc64le and riscv64 on FreeBSD ##debug * Also correct issue in vmenus.c, where ch is checked later whether it's -1, but on ARM and POWER, char is unsigned. --- libr/core/vmenus.c | 2 +- libr/debug/p/native/reg.c | 6 +++ libr/debug/p/native/reg/kfbsd-ppc.h | 51 ++++++++++++++++++++++ libr/debug/p/native/reg/kfbsd-ppc64.h | 56 +++++++++++++++++++++++++ libr/debug/p/native/reg/kfbsd-riscv64.h | 48 +++++++++++++++++++++ 5 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 libr/debug/p/native/reg/kfbsd-ppc.h create mode 100644 libr/debug/p/native/reg/kfbsd-ppc64.h create mode 100644 libr/debug/p/native/reg/kfbsd-riscv64.h diff --git a/libr/core/vmenus.c b/libr/core/vmenus.c index 880e8964edfd5..31b2d22d2a4af 100644 --- a/libr/core/vmenus.c +++ b/libr/core/vmenus.c @@ -3301,7 +3301,7 @@ R_API void r_core_visual_debugtraces(RCore *core, const char *input) { //int rows = r_cons_get_size (NULL); r_core_cmdf (core, "dtd %d", delta); r_cons_visual_flush (); - char ch ; + signed char ch; if (input && *input) { ch = *input; input++; diff --git a/libr/debug/p/native/reg.c b/libr/debug/p/native/reg.c index 2a1f2e07880d7..73bd6a6bceb10 100644 --- a/libr/debug/p/native/reg.c +++ b/libr/debug/p/native/reg.c @@ -49,6 +49,12 @@ static char *r_debug_native_reg_profile(RDebug *dbg) { #include "reg/kfbsd-x64.h" #elif __aarch64__ #include "reg/kfbsd-arm64.h" +#elif __powerpc64__ +#include "reg/kfbsd-ppc64.h" +#elif __powerpc__ +#include "reg/kfbsd-ppc.h" +#elif __riscv +#include "reg/kfbsd-riscv64.h" #else #error "Unsupported BSD architecture" #endif diff --git a/libr/debug/p/native/reg/kfbsd-ppc.h b/libr/debug/p/native/reg/kfbsd-ppc.h new file mode 100644 index 0000000000000..2b48ba083c95d --- /dev/null +++ b/libr/debug/p/native/reg/kfbsd-ppc.h @@ -0,0 +1,51 @@ +return strdup ( +"=PC srr0\n" +"=SP srr1\n" +"=SR srr1\n" // status register ?? +"=A0 r0\n" +"=A1 r1\n" +"=A2 r2\n" +"=A3 r3\n" +"gpr srr0 .32 0 0\n" +"gpr srr1 .32 4 0\n" +"gpr r0 .32 8 0\n" +"gpr r1 .32 12 0\n" +"gpr r2 .32 16 0\n" +"gpr r3 .32 20 0\n" +"gpr r4 .32 24 0\n" +"gpr r5 .32 28 0\n" +"gpr r6 .32 32 0\n" +"gpr r7 .32 36 0\n" +"gpr r8 .32 40 0\n" +"gpr r9 .32 44 0\n" +"gpr r10 .32 48 0\n" +"gpr r11 .32 52 0\n" +"gpr r12 .32 56 0\n" +"gpr r13 .32 60 0\n" +"gpr r14 .32 64 0\n" +"gpr r15 .32 68 0\n" +"gpr r16 .32 72 0\n" +"gpr r17 .32 76 0\n" +"gpr r18 .32 80 0\n" +"gpr r19 .32 84 0\n" +"gpr r20 .32 88 0\n" +"gpr r21 .32 92 0\n" +"gpr r22 .32 96 0\n" + +"gpr r23 .32 100 0\n" +"gpr r24 .32 104 0\n" +"gpr r25 .32 108 0\n" +"gpr r26 .32 112 0\n" +"gpr r27 .32 116 0\n" +"gpr r28 .32 120 0\n" +"gpr r29 .32 124 0\n" +"gpr r30 .32 128 0\n" +"gpr r31 .32 132 0\n" +"gpr cr .32 136 0\n" +"gpr xer .32 140 0\n" +"gpr lr .32 144 0\n" +"gpr ctr .32 148 0\n" +"gpr mq .32 152 0\n" +"gpr vrsave .32 156 0\n" +); + diff --git a/libr/debug/p/native/reg/kfbsd-ppc64.h b/libr/debug/p/native/reg/kfbsd-ppc64.h new file mode 100644 index 0000000000000..a3f093c430131 --- /dev/null +++ b/libr/debug/p/native/reg/kfbsd-ppc64.h @@ -0,0 +1,56 @@ +return strdup ( +"=PC pc\n" +"=SP r1\n" +"=A0 r3\n" +"=A1 r4\n" +"=A2 r5\n" +"=A3 r6\n" +"=A4 r7\n" +"=A5 r8\n" +"=A6 r9\n" +"=A7 r10\n" +"gpr r0 .64 0 0\n" +"gpr r1 .64 8 0\n" +"gpr r2 .64 16 0\n" +"gpr r3 .64 24 0\n" +"gpr r4 .64 32 0\n" +"gpr r5 .64 40 0\n" +"gpr r6 .64 48 0\n" +"gpr r7 .64 56 0\n" +"gpr r8 .64 64 0\n" +"gpr r9 .64 72 0\n" +"gpr r10 .64 80 0\n" +"gpr r11 .64 88 0\n" +"gpr r12 .64 96 0\n" +"gpr r13 .64 104 0\n" +"gpr r14 .64 112 0\n" +"gpr r15 .64 120 0\n" +"gpr r16 .64 128 0\n" +"gpr r17 .64 136 0\n" +"gpr r18 .64 144 0\n" +"gpr r19 .64 152 0\n" +"gpr r20 .64 160 0\n" +"gpr r21 .64 168 0\n" +"gpr r22 .64 176 0\n" +"gpr r23 .64 184 0\n" +"gpr r24 .64 192 0\n" +"gpr r25 .64 200 0\n" +"gpr r26 .64 208 0\n" +"gpr r27 .64 216 0\n" +"gpr r28 .64 224 0\n" +"gpr r29 .64 232 0\n" +"gpr r30 .64 240 0\n" +"gpr r31 .64 248 0\n" +"gpr pc .64 256 0\n" +"gpr msr .64 264 0\n" +"gpr orig_gpr3 .64 272 0\n" +"gpr ctr .64 280 0\n" +"gpr link .64 288 0\n" +"gpr xer .64 296 0\n" +"gpr ccr .64 304 0\n" +"gpr softe .64 312 0\n" +"gpr trap .64 320 0\n" +"gpr dar .64 328 0\n" +"gpr dsisr .64 336 0\n" +"gpr result .64 344 0\n" +); diff --git a/libr/debug/p/native/reg/kfbsd-riscv64.h b/libr/debug/p/native/reg/kfbsd-riscv64.h new file mode 100644 index 0000000000000..5b9658c47783d --- /dev/null +++ b/libr/debug/p/native/reg/kfbsd-riscv64.h @@ -0,0 +1,48 @@ +return strdup ( + "=PC pc\n" + "=SP x2\n" + "=BP x4\n" + "=R0 a10\n" + "=R1 a11\n" + "=A0 a10\n" + "=A1 a11\n" + "=A2 a12\n" + "=A3 a13\n" + "=A4 a14\n" + "gpr x0 .64 ? 0\n" // always zero + "gpr x1 .64 8 0\n" // RA - return address + "gpr x2 .64 16 0\n" // SP stack pointer + "gpr x3 .64 24 0\n" // GP global pointer + "gpr x4 .64 32 0\n" // TP thread pointer + "gpr x5 .64 40 0\n" // FP frame pointer -- BP + "gpr x6 .64 48 0\n" + "gpr x7 .64 56 0\n" + /* tmp */ + "gpr x8 .64 64 0\n" + "gpr x9 .64 72 0\n" + "gpr x10 .64 80 0\n" + "gpr x11 .64 88 0\n" + "gpr x12 .64 96 0\n" + "gpr x13 .64 104 0\n" + "gpr x14 .64 112 0\n" + "gpr x15 .64 120 0\n" + /* saved */ + "gpr x16 .64 128 0\n" + "gpr x17 .64 136 0\n" + "gpr x18 .64 144 0\n" + "gpr x19 .64 152 0\n" + "gpr x20 .64 160 0\n" + "gpr x21 .64 168 0\n" + "gpr x22 .64 176 0\n" + "gpr x23 .64 184 0\n" + /* tmp */ + "gpr x24 .64 192 0\n" + "gpr x25 .64 200 0\n" + /* special */ + "gpr x26 .64 208 0\n" + "gpr x27 .64 216 0\n" + "gpr x28 .64 224 0\n" + "gpr x29 .64 232 0\n" + "gpr x30 .64 240 0\n" + "gpr x31 .64 248 0\n" + ); From d24dbb9fbb0b398a6a739847008ccef3ea7e687c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20=C3=80lvarez=20i=20Capilla?= Date: Fri, 18 Feb 2022 20:15:37 +0100 Subject: [PATCH 041/390] Fix DoS on macho parser spotted by scan coverity ##crash --- libr/bin/format/mach0/mach0.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libr/bin/format/mach0/mach0.c b/libr/bin/format/mach0/mach0.c index a3472c81bfc2e..8313627507a5d 100644 --- a/libr/bin/format/mach0/mach0.c +++ b/libr/bin/format/mach0/mach0.c @@ -3151,6 +3151,13 @@ static void parse_relocation_info(struct MACH0_(obj_t) *bin, RSkipList *relocs, } ut64 total_size = num * sizeof (struct relocation_info); + if (offset > bin->size) { + return; + } + if (total_size > bin->size) { + total_size = bin->size - offset; + num = total_size /= sizeof (struct relocation_info); + } struct relocation_info *info = calloc (num, sizeof (struct relocation_info)); if (!info) { return; From 517cc28a31d79d7d3b28e09f2e67ea5cd8b6855e Mon Sep 17 00:00:00 2001 From: Dennis Goodlett Date: Sun, 20 Feb 2022 04:06:03 -0500 Subject: [PATCH 042/390] Fix uninitialized switch shift variable --- libr/anal/fcn.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libr/anal/fcn.c b/libr/anal/fcn.c index 229bbdf1d80fb..adc0656626282 100644 --- a/libr/anal/fcn.c +++ b/libr/anal/fcn.c @@ -987,7 +987,7 @@ static int fcn_recurse(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut64 len, int ut64 casetbl_addr = op->ptr; if (is_delta_pointer_table (anal, fcn, op->addr, op->ptr, &jmptbl_addr, &casetbl_addr, jmp_aop)) { ut64 table_size, default_case = 0; - st64 case_shift; + st64 case_shift = 0; // we require both checks here since try_get_jmptbl_info uses // BB info of the final jmptbl jump, which is no present with // is_delta_pointer_table just scanning ahead @@ -1228,7 +1228,7 @@ static int fcn_recurse(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut64 len, int // op->ireg is 0 for rip relative, "rax", etc otherwise if (op->ptr != UT64_MAX && op->ireg) { // direct jump ut64 table_size, default_case; - st64 case_shift; + st64 case_shift = 0; if (try_get_jmptbl_info (anal, fcn, op->addr, bb, &table_size, &default_case, &case_shift)) { bool case_table = false; RAnalOp *prev_op = r_anal_op_new (); @@ -1253,12 +1253,12 @@ static int fcn_recurse(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut64 len, int } } else if (op->ptr != UT64_MAX && op->reg) { // direct jump ut64 table_size, default_case; - st64 case_shift; + st64 case_shift = 0; if (try_get_jmptbl_info (anal, fcn, op->addr, bb, &table_size, &default_case, &case_shift)) { ret = try_walkthrough_jmptbl (anal, fcn, bb, depth - 1, op->addr, case_shift, op->ptr, op->ptr, anal->bits >> 3, table_size, default_case, ret); } } else if (movdisp != UT64_MAX) { - st64 case_shift; + st64 case_shift = 0; ut64 table_size, default_case; ut64 jmptbl_base = 0; //UT64_MAX; ut64 lea_op_off = UT64_MAX; From f36e518cde1738c1c01cf8368aeaccb6a17db83a Mon Sep 17 00:00:00 2001 From: Dennis Goodlett Date: Sun, 20 Feb 2022 03:59:42 -0500 Subject: [PATCH 043/390] Add agfma to get assembly in mermaid graphs ##anal --- libr/core/cmd_anal.c | 66 +++++++++++++++++++----- test/db/cmd/cmd_agf | 117 ++++++++++++++++++++++++++++++------------- 2 files changed, 136 insertions(+), 47 deletions(-) diff --git a/libr/core/cmd_anal.c b/libr/core/cmd_anal.c index e847076660102..9d3df687bba95 100644 --- a/libr/core/cmd_anal.c +++ b/libr/core/cmd_anal.c @@ -9703,7 +9703,43 @@ R_API void cmd_agfb2(RCore *core, const char *s) { free (pix); } -static bool cmd_graph_mermaid(RCore *core) { +static inline bool mermaid_add_node_asm(RAnal *a, RAnalBlock *bb, RStrBuf *nodes) { + ut8 *bb_buf = calloc (1, bb->size); + if (!bb_buf) { + return false; + } + if (!a->iob.read_at (a->iob.io, bb->addr, (ut8 *)bb_buf, bb->size)) { + return false; + } + RAnalOpMask mask = R_ANAL_OP_MASK_BASIC | R_ANAL_OP_MASK_DISASM | R_ANAL_OP_HINT_MASK; + RAnalOp op = { 0 }; + + // escaped newline to get out of title line + bool ret = r_strbuf_append (nodes, "\\n"); + int i; + for (i = 0; i < bb->ninstr; i++) { + const ut64 prev_pos = r_anal_bb_offset_inst (bb, i); + const ut64 op_addr = r_anal_bb_opaddr_i (bb, i); + if (prev_pos >= bb->size) { + continue; + } + int buflen = bb->size - prev_pos; + ut8 *loc = bb_buf + prev_pos; + if (r_anal_op (a, &op, op_addr, loc, buflen, mask) > 0) { + ret &= r_strbuf_appendf (nodes, "%s\\n", op.mnemonic); + } else { + ret &= r_strbuf_append (nodes, "...\\n"); + } + if (!ret) { + break; + } + r_anal_op_fini (&op); + } + free (bb_buf); + return ret; +} + +static bool cmd_graph_mermaid(RCore *core, bool add_asm) { RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, core->offset, 0); if (!fcn || !fcn->bbs) { return false; @@ -9723,21 +9759,25 @@ static bool cmd_graph_mermaid(RCore *core) { r_list_sort (fcn->bbs, bb_cmp); r_list_foreach (fcn->bbs, iter, b) { // node names start with _0x b/c 0x makes mermaids mad somehow - if (b->addr != fcn->addr) { - ret &= r_strbuf_appendf (nodes, "\tstate \"0x%" PFMT64x "\" as _0x%" PFMT64x "\n", b->addr, b->addr); - } else { - ret &= r_strbuf_appendf (nodes, "\tstate \"ENTRY: 0x%" PFMT64x "\" as _0x%" PFMT64x "\n", b->addr, b->addr); + ret &= r_strbuf_appendf (nodes, " state \"[0x%" PFMT64x "]", b->addr); + if (b->addr == fcn->addr) { + ret &= r_strbuf_appendf (nodes, " %s", fcn->name); + } + if (add_asm) { + ret &= mermaid_add_node_asm (core->anal, b, nodes); } - // TODO: make body contain assembly, this needs to be done with some care so characters are not misinterpreted + // ending of nodes string `... " as _0xfffff` + ret &= r_strbuf_appendf (nodes, "\" as _0x%" PFMT64x "\n", b->addr); + if (b->jump != UT64_MAX) { if (b->fail != UT64_MAX) { - ret &= r_strbuf_appendf (edges, "\t_0x%" PFMT64x " --> _0x%" PFMT64x ": true\n", b->addr, b->jump); - ret &= r_strbuf_appendf (edges, "\t_0x%" PFMT64x " --> _0x%" PFMT64x ": false\n", b->addr, b->fail); + ret &= r_strbuf_appendf (edges, " _0x%" PFMT64x " --> _0x%" PFMT64x ": true\n", b->addr, b->jump); + ret &= r_strbuf_appendf (edges, " _0x%" PFMT64x " --> _0x%" PFMT64x ": false\n", b->addr, b->fail); } else { - ret &= r_strbuf_appendf (edges, "\t_0x%" PFMT64x " --> _0x%" PFMT64x "\n", b->addr, b->jump); + ret &= r_strbuf_appendf (edges, " _0x%" PFMT64x " --> _0x%" PFMT64x "\n", b->addr, b->jump); } } else if (b->fail != UT64_MAX) { - ret &= r_strbuf_appendf (edges, "\t_0x%" PFMT64x " --> _0x%" PFMT64x "\n", b->addr, b->fail); + ret &= r_strbuf_appendf (edges, " _0x%" PFMT64x " --> _0x%" PFMT64x "\n", b->addr, b->fail); } if (!ret) { break; @@ -9772,8 +9812,10 @@ static void cmd_anal_graph(RCore *core, const char *input) { cmd_agfb (core); break; case 'm': /// "agfm" // mermaid - cmd_graph_mermaid (core); - break; + { + bool add_asm = input[2] == 'a'? true: false; + cmd_graph_mermaid (core, add_asm); + } break; case ' ': { // "agf " RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, core->offset, 0); r_core_visual_graph (core, NULL, fcn, false); diff --git a/test/db/cmd/cmd_agf b/test/db/cmd/cmd_agf index 3aeb4ea01c10d..755f613ea3ce3 100644 --- a/test/db/cmd/cmd_agf +++ b/test/db/cmd/cmd_agf @@ -71,40 +71,87 @@ agfm EOF EXPECT=< _0x15db5: true - _0x15cc0 --> _0x15d06: false - _0x15d06 --> _0x15db5: true - _0x15d06 --> _0x15d12: false - _0x15d12 --> _0x15db5: true - _0x15d12 --> _0x15d29: false - _0x15d29 --> _0x15d7e: true - _0x15d29 --> _0x15d67: false - _0x15d67 --> _0x15da0: true - _0x15d67 --> _0x15d7e: false - _0x15da0 --> _0x15d7e - _0x15db5 --> _0x15df6: true - _0x15db5 --> _0x15dc9: false - _0x15dc9 --> _0x15dd0 - _0x15dd0 --> _0x15dda: true - _0x15dd0 --> _0x15dd5: false - _0x15dd5 --> _0x15df0: true - _0x15dd5 --> _0x15dda: false - _0x15dda --> _0x15dd0: true - _0x15dda --> _0x15de3: false + state "[0x15cc0] sym._obstack_newchunk" as _0x15cc0 + state "[0x15d06]" as _0x15d06 + state "[0x15d12]" as _0x15d12 + state "[0x15d29]" as _0x15d29 + state "[0x15d67]" as _0x15d67 + state "[0x15d7e]" as _0x15d7e + state "[0x15da0]" as _0x15da0 + state "[0x15db5]" as _0x15db5 + state "[0x15dc9]" as _0x15dc9 + state "[0x15dd0]" as _0x15dd0 + state "[0x15dd5]" as _0x15dd5 + state "[0x15dda]" as _0x15dda + state "[0x15de3]" as _0x15de3 + state "[0x15df0]" as _0x15df0 + state "[0x15df6]" as _0x15df6 + _0x15cc0 --> _0x15db5: true + _0x15cc0 --> _0x15d06: false + _0x15d06 --> _0x15db5: true + _0x15d06 --> _0x15d12: false + _0x15d12 --> _0x15db5: true + _0x15d12 --> _0x15d29: false + _0x15d29 --> _0x15d7e: true + _0x15d29 --> _0x15d67: false + _0x15d67 --> _0x15da0: true + _0x15d67 --> _0x15d7e: false + _0x15da0 --> _0x15d7e + _0x15db5 --> _0x15df6: true + _0x15db5 --> _0x15dc9: false + _0x15dc9 --> _0x15dd0 + _0x15dd0 --> _0x15dda: true + _0x15dd0 --> _0x15dd5: false + _0x15dd5 --> _0x15df0: true + _0x15dd5 --> _0x15dda: false + _0x15dda --> _0x15dd0: true + _0x15dda --> _0x15de3: false +EOF +RUN + +NAME=agfma basic mermaid output +FILE=bins/elf/ls +CMDS=< _0x15db5: true + _0x15cc0 --> _0x15d06: false + _0x15d06 --> _0x15db5: true + _0x15d06 --> _0x15d12: false + _0x15d12 --> _0x15db5: true + _0x15d12 --> _0x15d29: false + _0x15d29 --> _0x15d7e: true + _0x15d29 --> _0x15d67: false + _0x15d67 --> _0x15da0: true + _0x15d67 --> _0x15d7e: false + _0x15da0 --> _0x15d7e + _0x15db5 --> _0x15df6: true + _0x15db5 --> _0x15dc9: false + _0x15dc9 --> _0x15dd0 + _0x15dd0 --> _0x15dda: true + _0x15dd0 --> _0x15dd5: false + _0x15dd5 --> _0x15df0: true + _0x15dd5 --> _0x15dda: false + _0x15dda --> _0x15dd0: true + _0x15dda --> _0x15de3: false EOF RUN From b6b56e700a58f0251eade736ef37ae0cab27b454 Mon Sep 17 00:00:00 2001 From: Dennis Goodlett Date: Sat, 19 Feb 2022 17:08:46 -0500 Subject: [PATCH 044/390] Handle jump tables in agfm ##anal --- libr/core/cmd_anal.c | 17 ++++++++++++++++- test/db/cmd/cmd_agf | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/libr/core/cmd_anal.c b/libr/core/cmd_anal.c index 9d3df687bba95..13b9cac5dfe75 100644 --- a/libr/core/cmd_anal.c +++ b/libr/core/cmd_anal.c @@ -9739,6 +9739,20 @@ static inline bool mermaid_add_node_asm(RAnal *a, RAnalBlock *bb, RStrBuf *nodes return ret; } +static inline bool fcn_siwtch_mermaid(RAnalBlock *b, RStrBuf *buf) { + if (b->switch_op) { + r_return_val_if_fail (b->switch_op->cases, false); + RListIter *itt; + RAnalCaseOp *c; + r_list_foreach (b->switch_op->cases, itt, c) { + if (!r_strbuf_appendf (buf, " _0x%" PFMT64x " --> _0x%" PFMT64x ": Case %" PFMT64d "\n", b->addr, c->addr, c->value)) { + return false; + } + } + } + return true; +} + static bool cmd_graph_mermaid(RCore *core, bool add_asm) { RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, core->offset, 0); if (!fcn || !fcn->bbs) { @@ -9758,7 +9772,6 @@ static bool cmd_graph_mermaid(RCore *core, bool add_asm) { r_list_sort (fcn->bbs, bb_cmp); r_list_foreach (fcn->bbs, iter, b) { - // node names start with _0x b/c 0x makes mermaids mad somehow ret &= r_strbuf_appendf (nodes, " state \"[0x%" PFMT64x "]", b->addr); if (b->addr == fcn->addr) { ret &= r_strbuf_appendf (nodes, " %s", fcn->name); @@ -9767,6 +9780,7 @@ static bool cmd_graph_mermaid(RCore *core, bool add_asm) { ret &= mermaid_add_node_asm (core->anal, b, nodes); } // ending of nodes string `... " as _0xfffff` + // node names start with _0x b/c 0x makes mermaids mad somehow ret &= r_strbuf_appendf (nodes, "\" as _0x%" PFMT64x "\n", b->addr); if (b->jump != UT64_MAX) { @@ -9779,6 +9793,7 @@ static bool cmd_graph_mermaid(RCore *core, bool add_asm) { } else if (b->fail != UT64_MAX) { ret &= r_strbuf_appendf (edges, " _0x%" PFMT64x " --> _0x%" PFMT64x "\n", b->addr, b->fail); } + ret &= fcn_siwtch_mermaid (b, edges); if (!ret) { break; } diff --git a/test/db/cmd/cmd_agf b/test/db/cmd/cmd_agf index 755f613ea3ce3..e41b131c944dc 100644 --- a/test/db/cmd/cmd_agf +++ b/test/db/cmd/cmd_agf @@ -155,3 +155,44 @@ stateDiagram-v2 _0x15dda --> _0x15de3: false EOF RUN + +NAME=agfm on jump table +CMDS=< _0x8a: true + _0x10 --> _0x34: false + _0x34 --> _0x42: Case 0 + _0x34 --> _0x4e: Case 1 + _0x34 --> _0x5a: Case 2 + _0x34 --> _0x66: Case 3 + _0x34 --> _0x72: Case 4 + _0x34 --> _0x7e: Case 5 + _0x42 --> _0x91 + _0x4e --> _0x91 + _0x5a --> _0x91 + _0x66 --> _0x91 + _0x72 --> _0x91 + _0x7e --> _0x91 + _0x8a --> _0x91 +EOF +RUN From 1face81feb86ccb707ac7ccaa43996dfe6eb7b11 Mon Sep 17 00:00:00 2001 From: pancake Date: Sun, 20 Feb 2022 16:57:04 +0100 Subject: [PATCH 045/390] Fix #19737 - Handle ESC and space in the ascii hex column ##visual --- libr/core/visual.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libr/core/visual.c b/libr/core/visual.c index 9f2b46760b1f4..12a3f0eca507b 100644 --- a/libr/core/visual.c +++ b/libr/core/visual.c @@ -2111,9 +2111,19 @@ static bool insert_mode_enabled(RCore *core) { } if (core->print->col == 2) { /* ascii column */ - if (IS_PRINTABLE (ch)) { - r_core_cmdf (core, "\"w %c\" @ $$+%d", ch, core->print->cur); + switch (ch) { + case 0x1b: // ESC + core->print->col = 0; + break; + case ' ': + r_core_cmdf (core, "wx 20 @ $$+%d", core->print->cur); core->print->cur++; + break; + default: + if (IS_PRINTABLE (ch)) { + r_core_cmdf (core, "\"w %c\" @ $$+%d", ch, core->print->cur); + core->print->cur++; + } } return true; } else { From 6691d809893a2ae6ccde49f66cbef00a200b891d Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 21 Feb 2022 13:03:50 +0100 Subject: [PATCH 046/390] Fix #19739 - Fix oobread in pv* and fix bug in pvj ##print --- libr/core/cmd_print.c | 20 ++++---- test/db/cmd/cmd_print | 95 ++++++++++++++++++++++++++++++++++++++ test/db/cmd/cmd_print_misc | 2 +- 3 files changed, 107 insertions(+), 10 deletions(-) diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index 1ec787b14ecd5..b1774c9be327d 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -3251,7 +3251,9 @@ static void cmd_print_pv(RCore *core, const char *input, bool useBytes) { for (i = 0; i < repeat; i++) { const bool be = core->print->big_endian; ut64 at = core->offset + (i * n); - ut8 *b = block + (i * n); + ut8 buf[8]; + r_io_read_at (core->io, at, buf, sizeof (buf)); + ut8 *b = buf; switch (n) { case 1: r_cons_printf ("f pval.0x%08"PFMT64x"=%d\n", at, r_read_ble8 (b)); @@ -3277,10 +3279,10 @@ static void cmd_print_pv(RCore *core, const char *input, bool useBytes) { } pj_a (pj); ut64 at = core->offset; - ut64 oldAt = at; for (i = 0; i < repeat; i++) { - r_core_seek (core, at, false); - char *str = r_core_cmd_str (core, "ps"); + ut8 buf[8]; + r_io_read_at (core->io, at, buf, sizeof (buf)); + char *str = r_core_cmd_strf (core, "ps@0x%"PFMT64x, at); r_str_trim (str); char *p = str; if (p) { @@ -3298,20 +3300,21 @@ static void cmd_print_pv(RCore *core, const char *input, bool useBytes) { pj_k (pj, "value"); switch (n) { case 1: - pj_i (pj, r_read_ble8 (block)); + pj_i (pj, r_read_ble8 (buf)); break; case 2: - pj_i (pj, r_read_ble16 (block, core->print->big_endian)); + pj_i (pj, r_read_ble16 (buf, core->print->big_endian)); break; case 4: - pj_n (pj, (ut64)r_read_ble32 (block, core->print->big_endian)); + pj_n (pj, (ut64)r_read_ble32 (buf, core->print->big_endian)); break; case 8: default: - pj_n (pj, r_read_ble64 (block, core->print->big_endian)); + pj_n (pj, r_read_ble64 (buf, core->print->big_endian)); break; } pj_ks (pj, "string", str); + pj_kn (pj, "address", at); pj_end (pj); free (str); at += n; @@ -3319,7 +3322,6 @@ static void cmd_print_pv(RCore *core, const char *input, bool useBytes) { pj_end (pj); r_cons_println (pj_string (pj)); pj_free (pj); - r_core_seek (core, oldAt, false); break; } case 'e': // "pve" diff --git a/test/db/cmd/cmd_print b/test/db/cmd/cmd_print index ddad086be4481..0f76ac2f8d83f 100644 --- a/test/db/cmd/cmd_print +++ b/test/db/cmd/cmd_print @@ -20,6 +20,101 @@ EXPECT=<?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x80\\x82\\x84\\x86\\x88\\x8a\\x8c\\x8e\\x90\\x92\\x94\\x96\\x98\\x9a\\x9c\\x9e\\xa0\\xa2\\xa4\\xa6\\xa8\\xaa\\xac\\xae\\xb0\\xb2\\xb4\\xb6\\xb8\\xba\\xbc\\xbe\\xc0\\xc2\\xc4\\xc6\\xc8\\xca\\xcc\\xce\\xd0\\xd2\\xd4\\xd6\\xd8\\xda\\xdc\\xde\\xe0\\xe2\\xe4\\xe6\\xe8\\xea\\xec\\xee\\xf0\\xf2\\xf4\\xf6\\xf8\\xfa\\xfc\\xfe", + "address": 8 + }, + { + "value": 1663540288323457296, + "string": "\\x11\\x13\\x15\\x17\\x19\\x1b\\x1d\\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x80\\x82\\x84\\x86\\x88\\x8a\\x8c\\x8e\\x90\\x92\\x94\\x96\\x98\\x9a\\x9c\\x9e\\xa0\\xa2\\xa4\\xa6\\xa8\\xaa\\xac\\xae\\xb0\\xb2\\xb4\\xb6\\xb8\\xba\\xbc\\xbe\\xc0\\xc2\\xc4\\xc6\\xc8\\xca\\xcc\\xce\\xd0\\xd2\\xd4\\xd6\\xd8\\xda\\xdc\\xde\\xe0\\xe2\\xe4\\xe6\\xe8\\xea\\xec\\xee\\xf0\\xf2\\xf4\\xf6\\xf8\\xfa\\xfc\\xfe", + "address": 16 + } +] +-- +[ + { + "value": 256, + "string": "", + "address": 0 + }, + { + "value": 770, + "string": "\\x03\\x05\\x07\\x09\n\\x0c\\x0e\\x10\\x12\\x14\\x16\\x18\\x1a\\x1c\\x1e !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x80\\x82\\x84\\x86\\x88\\x8a\\x8c\\x8e\\x90\\x92\\x94\\x96\\x98\\x9a\\x9c\\x9e\\xa0\\xa2\\xa4\\xa6\\xa8\\xaa\\xac\\xae\\xb0\\xb2\\xb4\\xb6\\xb8\\xba\\xbc\\xbe\\xc0\\xc2\\xc4\\xc6\\xc8\\xca\\xcc\\xce\\xd0\\xd2\\xd4\\xd6\\xd8\\xda\\xdc\\xde\\xe0\\xe2\\xe4\\xe6\\xe8\\xea\\xec\\xee\\xf0\\xf2\\xf4\\xf6\\xf8\\xfa\\xfc\\xfe", + "address": 2 + }, + { + "value": 1284, + "string": "\\x05\\x07\\x09\n\\x0c\\x0e\\x10\\x12\\x14\\x16\\x18\\x1a\\x1c\\x1e !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x80\\x82\\x84\\x86\\x88\\x8a\\x8c\\x8e\\x90\\x92\\x94\\x96\\x98\\x9a\\x9c\\x9e\\xa0\\xa2\\xa4\\xa6\\xa8\\xaa\\xac\\xae\\xb0\\xb2\\xb4\\xb6\\xb8\\xba\\xbc\\xbe\\xc0\\xc2\\xc4\\xc6\\xc8\\xca\\xcc\\xce\\xd0\\xd2\\xd4\\xd6\\xd8\\xda\\xdc\\xde\\xe0\\xe2\\xe4\\xe6\\xe8\\xea\\xec\\xee\\xf0\\xf2\\xf4\\xf6\\xf8\\xfa\\xfc\\xfe", + "address": 4 + } +] +-- +[ + { + "value": 0, + "string": "", + "address": 0 + }, + { + "value": 1, + "string": "\\x02\\x04\\x06\\x08\n\\x0c\\x0e\\x10\\x12\\x14\\x16\\x18\\x1a\\x1c\\x1e !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x80\\x82\\x84\\x86\\x88\\x8a\\x8c\\x8e\\x90\\x92\\x94\\x96\\x98\\x9a\\x9c\\x9e\\xa0\\xa2\\xa4\\xa6\\xa8\\xaa\\xac\\xae\\xb0\\xb2\\xb4\\xb6\\xb8\\xba\\xbc\\xbe\\xc0\\xc2\\xc4\\xc6\\xc8\\xca\\xcc\\xce\\xd0\\xd2\\xd4\\xd6\\xd8\\xda\\xdc\\xde\\xe0\\xe2\\xe4\\xe6\\xe8\\xea\\xec\\xee\\xf0\\xf2\\xf4\\xf6\\xf8\\xfa\\xfc\\xfe", + "address": 1 + }, + { + "value": 2, + "string": "\\x03\\x05\\x07\\x09\n\\x0c\\x0e\\x10\\x12\\x14\\x16\\x18\\x1a\\x1c\\x1e !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x80\\x82\\x84\\x86\\x88\\x8a\\x8c\\x8e\\x90\\x92\\x94\\x96\\x98\\x9a\\x9c\\x9e\\xa0\\xa2\\xa4\\xa6\\xa8\\xaa\\xac\\xae\\xb0\\xb2\\xb4\\xb6\\xb8\\xba\\xbc\\xbe\\xc0\\xc2\\xc4\\xc6\\xc8\\xca\\xcc\\xce\\xd0\\xd2\\xd4\\xd6\\xd8\\xda\\xdc\\xde\\xe0\\xe2\\xe4\\xe6\\xe8\\xea\\xec\\xee\\xf0\\xf2\\xf4\\xf6\\xf8\\xfa\\xfc\\xfe", + "address": 2 + } +] +-- +[ + { + "value": 506097522914230528, + "string": "", + "address": 0 + }, + { + "value": 1084818905618843912, + "string": "\\x09\n\\x0c\\x0e\\x10\\x12\\x14\\x16\\x18\\x1a\\x1c\\x1e !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x80\\x82\\x84\\x86\\x88\\x8a\\x8c\\x8e\\x90\\x92\\x94\\x96\\x98\\x9a\\x9c\\x9e\\xa0\\xa2\\xa4\\xa6\\xa8\\xaa\\xac\\xae\\xb0\\xb2\\xb4\\xb6\\xb8\\xba\\xbc\\xbe\\xc0\\xc2\\xc4\\xc6\\xc8\\xca\\xcc\\xce\\xd0\\xd2\\xd4\\xd6\\xd8\\xda\\xdc\\xde\\xe0\\xe2\\xe4\\xe6\\xe8\\xea\\xec\\xee\\xf0\\xf2\\xf4\\xf6\\xf8\\xfa\\xfc\\xfe", + "address": 8 + }, + { + "value": 1663540288323457296, + "string": "\\x11\\x13\\x15\\x17\\x19\\x1b\\x1d\\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x80\\x82\\x84\\x86\\x88\\x8a\\x8c\\x8e\\x90\\x92\\x94\\x96\\x98\\x9a\\x9c\\x9e\\xa0\\xa2\\xa4\\xa6\\xa8\\xaa\\xac\\xae\\xb0\\xb2\\xb4\\xb6\\xb8\\xba\\xbc\\xbe\\xc0\\xc2\\xc4\\xc6\\xc8\\xca\\xcc\\xce\\xd0\\xd2\\xd4\\xd6\\xd8\\xda\\xdc\\xde\\xe0\\xe2\\xe4\\xe6\\xe8\\xea\\xec\\xee\\xf0\\xf2\\xf4\\xf6\\xf8\\xfa\\xfc\\xfe", + "address": 16 + } +] +-- +EOF +RUN + NAME=pv3 FILE=malloc://1024 CMDS=< Date: Mon, 21 Feb 2022 15:00:04 +0100 Subject: [PATCH 047/390] Fix #19729 - Make pswj consistent with psw output ##print --- libr/core/cmd_print.c | 24 ++++++++++++++++++++++-- test/db/cmd/cmd_ps | 13 +++++++++++++ test/db/cmd/cmd_psj | 2 +- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index b1774c9be327d..0a6e6a2fbfb26 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -4701,6 +4701,23 @@ static void print_json_string(RCore *core, const char* block, int len, const cha default: type = "unknown"; break; } } + bool is_wide = !strcmp (type, "wide"); + size_t slen = r_str_nlen (block, len); + char *tblock = (char *)block; + if (is_wide) { + int i; + // dewide + tblock = r_mem_dup (block, len); + for (i = 0; i < len; i++) { + if (tblock[i] && !tblock[i + 1]) { + memmove (tblock + i + 1, tblock + i + 2, len - i - 1); + } else { + tblock[i] = 0; + break; + } + } + slen = strlen (tblock); + } PJ *pj = r_core_pj_new (core); if (!pj) { return; @@ -4708,18 +4725,21 @@ static void print_json_string(RCore *core, const char* block, int len, const cha pj_o (pj); pj_k (pj, "string"); // TODO: add pj_kd for data to pass key(string) and value(data,len) instead of pj_ks which null terminates - char *str = r_str_utf16_encode (block, len); // XXX just block + len should be fine, pj takes care of this + char *str = r_str_utf16_encode (tblock, slen); // XXX just block + len should be fine, pj takes care of this pj_raw (pj, "\""); pj_raw (pj, str); free (str); pj_raw (pj, "\""); pj_kn (pj, "offset", core->offset); pj_ks (pj, "section", section_name); - pj_ki (pj, "length", len); + pj_ki (pj, "length", slen); pj_ks (pj, "type", type); pj_end (pj); r_cons_println (pj_string (pj)); pj_free (pj); + if (tblock != block) { + free (tblock); + } } static char *__op_refs(RCore *core, RAnalOp *op, int n) { diff --git a/test/db/cmd/cmd_ps b/test/db/cmd/cmd_ps index 7b8ba69f07f24..94318e6eb1b7e 100644 --- a/test/db/cmd/cmd_ps +++ b/test/db/cmd/cmd_ps @@ -102,3 +102,16 @@ EXPECT_ERR=< Date: Mon, 21 Feb 2022 18:01:56 +0100 Subject: [PATCH 048/390] Fix DoS in the minidump parser ##crash * Reported by lazymio via huntr.dev * Reproducer: mdmp-dos --- libr/bin/format/mdmp/mdmp.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/libr/bin/format/mdmp/mdmp.c b/libr/bin/format/mdmp/mdmp.c index ec802d5a7ac8c..4cfe6015dfffd 100644 --- a/libr/bin/format/mdmp/mdmp.c +++ b/libr/bin/format/mdmp/mdmp.c @@ -369,9 +369,15 @@ static bool r_bin_mdmp_init_hdr(struct r_bin_mdmp_obj *obj) { return true; } -static void read_module(RBuffer *b, ut64 addr, struct minidump_module *module) { +static struct minidump_module *read_module(RBuffer *b, ut64 addr) { st64 o_addr = r_buf_seek (b, 0, R_BUF_CUR); - r_buf_seek (b, addr, R_BUF_SET); + if (r_buf_seek (b, addr, R_BUF_SET) == -1) { + return NULL; + } + struct minidump_module *module = R_NEW0 (struct minidump_module); + if (!module) { + return NULL; + } module->base_of_image = r_buf_read_le64 (b); module->size_of_image = r_buf_read_le32 (b); module->check_sum = r_buf_read_le32 (b); @@ -397,6 +403,7 @@ static void read_module(RBuffer *b, ut64 addr, struct minidump_module *module) { module->reserved_0 = r_buf_read_le64 (b); module->reserved_1 = r_buf_read_le64 (b); r_buf_seek (b, o_addr, R_BUF_SET); + return module; } static void read_memory64_list(RBuffer *b, ut64 addr, struct minidump_memory64_list *memory64_list) { @@ -477,12 +484,11 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m 0); offset = entry->location.rva + sizeof (module_list); - for (i = 0; i < module_list.number_of_modules; i++) { - struct minidump_module *module = R_NEW (struct minidump_module); + for (i = 0; i < module_list.number_of_modules && offset < obj->size; i++) { + struct minidump_module *module = read_module (obj->b, offset); if (!module) { - break; + break; } - read_module (obj->b, offset, module); r_list_append (obj->streams.modules, module); offset += sizeof (*module); } @@ -503,7 +509,7 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m 0); offset = entry->location.rva + sizeof (memory_list); - for (i = 0; i < memory_list.number_of_memory_ranges; i++) { + for (i = 0; i < memory_list.number_of_memory_ranges && offset < obj->size; i++) { struct minidump_memory_descriptor *desc = R_NEW (struct minidump_memory_descriptor); if (!desc) { break; @@ -586,7 +592,7 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m 0); offset = entry->location.rva + sizeof (thread_ex_list); - for (i = 0; i < thread_ex_list.number_of_threads; i++) { + for (i = 0; i < thread_ex_list.number_of_threads && offset < obj->size; i++) { struct minidump_thread_ex *thread = R_NEW (struct minidump_thread_ex); if (!thread) { break; @@ -613,7 +619,7 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m obj->streams.memories64.base_rva = memory64_list.base_rva; offset = entry->location.rva + sizeof (memory64_list); - for (i = 0; i < memory64_list.number_of_memory_ranges; i++) { + for (i = 0; i < memory64_list.number_of_memory_ranges && offset < obj->size; i++) { struct minidump_memory_descriptor64 *desc = R_NEW (struct minidump_memory_descriptor64); if (!desc) { break; @@ -708,7 +714,7 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m "SizeOfHeader SizeOfEntry NumberOfEntries", 0); offset = entry->location.rva + sizeof (unloaded_module_list); - for (i = 0; i < unloaded_module_list.number_of_entries; i++) { + for (i = 0; i < unloaded_module_list.number_of_entries && offset < obj->size; i++) { struct minidump_unloaded_module *module = R_NEW (struct minidump_unloaded_module); if (!module) { break; @@ -763,7 +769,7 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m 0); offset = entry->location.rva + sizeof (memory_info_list); - for (i = 0; i < memory_info_list.number_of_entries; i++) { + for (i = 0; i < memory_info_list.number_of_entries && offset < obj->size; i++) { struct minidump_memory_info *info = R_NEW (struct minidump_memory_info); if (!info) { break; @@ -793,7 +799,7 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m "SizeOfHeader SizeOfEntry NumberOfEntries", 0); offset = entry->location.rva + sizeof (thread_info_list); - for (i = 0; i < thread_info_list.number_of_entries; i++) { + for (i = 0; i < thread_info_list.number_of_entries && offset < obj->size; i++) { struct minidump_thread_info *info = R_NEW (struct minidump_thread_info); if (!info) { break; @@ -819,7 +825,7 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m "SizeOfHeader SizeOfEntry NumberOfEntries Reserved", 0); offset = entry->location.rva + sizeof (handle_operation_list); - for (i = 0; i < handle_operation_list.number_of_entries; i++) { + for (i = 0; i < handle_operation_list.number_of_entries && offset < obj->size; i++) { struct avrf_handle_operation *op = R_NEW (struct avrf_handle_operation); if (!op) { break; @@ -849,7 +855,7 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m "TokenListSize TokenListEntries ListHeaderSize ElementHeaderSize", 0); offset = entry->location.rva + sizeof (token_info_list); - for (i = 0; i < token_info_list.number_of_entries; i++) { + for (i = 0; i < token_info_list.number_of_entries && offset < obj->size; i++) { struct minidump_token_info *info = R_NEW (struct minidump_token_info); if (!info) { break; From 515e592b9bea0612bc63d8e93239ff35bcf645c7 Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 21 Feb 2022 18:45:06 +0100 Subject: [PATCH 049/390] Fix null deref in bin.symbols ##crash * Reported by cnitlrt via huntr.dev --- libr/bin/p/bin_symbols.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libr/bin/p/bin_symbols.c b/libr/bin/p/bin_symbols.c index 394736cfffbd3..183507d2d2b21 100644 --- a/libr/bin/p/bin_symbols.c +++ b/libr/bin/p/bin_symbols.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2018 - pancake */ +/* radare - LGPL - Copyright 2018-2022 - pancake */ #include #include @@ -361,6 +361,9 @@ static RList *symbols(RBinFile *bf) { bool found = false; for (i = 0; i < element->hdr->n_lined_symbols; i++) { RCoreSymCacheElementSymbol *sym = (RCoreSymCacheElementSymbol *)&element->lined_symbols[i]; + if (!sym) { + break; + } ht_uu_find (hash, sym->paddr, &found); if (found) { continue; From a35f89f86ed12161af09330e92e5a213014e46a1 Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 21 Feb 2022 19:25:02 +0100 Subject: [PATCH 050/390] Fix oobread in macho core symbolication ##crash * Reported by @cnitlrt via huntr.dev --- libr/bin/format/mach0/coresymbolication.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libr/bin/format/mach0/coresymbolication.c b/libr/bin/format/mach0/coresymbolication.c index 5385509f32491..f350199550b50 100644 --- a/libr/bin/format/mach0/coresymbolication.c +++ b/libr/bin/format/mach0/coresymbolication.c @@ -222,7 +222,7 @@ RCoreSymCacheElement *r_coresym_cache_element_new(RBinFile *bf, RBuffer *buf, ut } size_t i; ut8 *cursor = b + R_CS_EL_OFF_SEGS; - for (i = 0; i < hdr->n_segments && cursor < end; i++) { + for (i = 0; i < hdr->n_segments && cursor + sizeof (RCoreSymCacheElementSegment) < end; i++) { RCoreSymCacheElementSegment *seg = &result->segments[i]; seg->paddr = seg->vaddr = r_read_le64 (cursor); cursor += 8; From cfc1c5d2023a90817b008564f8bda6bcf1140e04 Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 21 Feb 2022 19:32:51 +0100 Subject: [PATCH 051/390] Fix #19726 - fix meson definition order issue when using syslz4 ##build --- libr/util/meson.build | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libr/util/meson.build b/libr/util/meson.build index f2613e5c03b0f..745fe2fc897c8 100644 --- a/libr/util/meson.build +++ b/libr/util/meson.build @@ -96,6 +96,7 @@ if get_option('sdb_cgen') r_util_sources += r_util_d_sources endif +r_util_deps = [ldl, mth, spp_dep, pth, utl, sdb_dep, zlib_dep, platform_deps] if lz4_dep.found() and get_option('use_sys_lz4') # r_util_deps += lz4_dep r_util_deps += declare_dependency( @@ -105,8 +106,6 @@ if lz4_dep.found() and get_option('use_sys_lz4') else r_util_sources += '../../shlr/lz4/lz4.c' endif - -r_util_deps = [ldl, mth, spp_dep, pth, utl, sdb_dep, zlib_dep, platform_deps] if host_machine.system().startswith('freebsd') or host_machine.system().startswith('netbsd') or host_machine.system().startswith('haiku') # backtrace_symbols_fd requires -lexecinfo r_util_deps += [cc.find_library('execinfo')] From ddc7458b4b9f22cd866a13adec420c22fad760f4 Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 21 Feb 2022 21:00:55 +0100 Subject: [PATCH 052/390] Reorder master-specific CI workflows to the bottom --- .github/workflows/ci.yml | 58 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1c5d6ac2d023..9696d35808ab7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,6 +95,35 @@ jobs: run: sudo make uninstall - name: Reinstalling without symlinks run: sudo make install + linux-test: + runs-on: ubuntu-20.04 +# if: contains(github.ref, 'ci-') + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Building Radare2 + run: | + pip install r2pipe wheel + export CFLAGS="-O2 -Wno-unused-result" + sys/install.sh + - name: Running tests + run: | + export LD_LIBRARY_PATH=/usr/local/lib + make tests + macos-test: + runs-on: macos-latest + if: contains(github.ref, 'master') || contains(github.ref, 'ci-') + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install r2pipe + - name: Building Radare2 + run: export CFLAGS="-O2"; sys/install.sh + - name: Running tests + run: pip3 install r2pipe; make tests build-rpath-linux: if: contains(github.ref, 'master') || contains(github.ref, 'ci-') name: linux-rpath @@ -193,32 +222,3 @@ jobs: export R2R_SKIP_ARCHOS=1 export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.5 make -C test fuzz-tests - linux-test: - runs-on: ubuntu-20.04 -# if: contains(github.ref, 'ci-') - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Building Radare2 - run: | - pip install r2pipe wheel - export CFLAGS="-O2 -Wno-unused-result" - sys/install.sh - - name: Running tests - run: | - export LD_LIBRARY_PATH=/usr/local/lib - make tests - macos-test: - runs-on: macos-latest - if: contains(github.ref, 'master') || contains(github.ref, 'ci-') - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install r2pipe - - name: Building Radare2 - run: export CFLAGS="-O2"; sys/install.sh - - name: Running tests - run: pip3 install r2pipe; make tests From 3b774834dcc4c4d1cf78e4675c05589e77d8f969 Mon Sep 17 00:00:00 2001 From: archcloudlabs <1250113+archcloudlabs@users.noreply.github.com> Date: Mon, 21 Feb 2022 17:21:10 -0500 Subject: [PATCH 053/390] Adding NULL check to prevent segfault --- libr/bin/format/ne/ne.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libr/bin/format/ne/ne.c b/libr/bin/format/ne/ne.c index ce9b604452751..8647af4d9a072 100644 --- a/libr/bin/format/ne/ne.c +++ b/libr/bin/format/ne/ne.c @@ -49,6 +49,9 @@ static char *__read_nonnull_str_at(RBuffer *buf, ut64 offset) { } static char *__func_name_from_ord(const char *module, ut16 ordinal) { + if (!module) { + return NULL; + } char *lower_module = strdup (module); r_str_case (lower_module, false); char *path = r_str_newf (R_JOIN_4_PATHS ("%s", R2_SDB_FORMAT, "dll", "%s.sdb"), r_sys_prefix (NULL), lower_module); From 6500381f5e61f8eb49a0774f292403193b364896 Mon Sep 17 00:00:00 2001 From: aemmitt-ns <51972960+aemmitt-ns@users.noreply.github.com> Date: Tue, 22 Feb 2022 18:28:11 -0500 Subject: [PATCH 054/390] Fix operands that have an extension plus a shift (#19746) * check op.shiftType for sign extensions in addition to op.extend --- libr/anal/p/anal_arm_v35.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libr/anal/p/anal_arm_v35.c b/libr/anal/p/anal_arm_v35.c index c4a119bf08201..de8b6a807939d 100644 --- a/libr/anal/p/anal_arm_v35.c +++ b/libr/anal/p/anal_arm_v35.c @@ -248,6 +248,16 @@ static const char *decode_shift_64(ShiftType shift) { case ShiftType_LSR: return E_OP_SR; + // need to include these "shifts" + case ShiftType_SXTB: + case ShiftType_SXTW: + case ShiftType_SXTH: + case ShiftType_SXTX: + case ShiftType_UXTB: + case ShiftType_UXTW: + case ShiftType_UXTH: + case ShiftType_UXTX: + case ShiftType_LSL: case ShiftType_MSL: return E_OP_SL; @@ -621,6 +631,12 @@ static void arg64_append(RStrBuf *sb, Instruction *insn, int n, int i, int sign) int shift = LSHIFT2_64 (n); int signext = EXT64 (n); + if (!signext) { + // this is weird but signext+shift is all in shiftType? + // not extend. why even have an extend field? + // why not just shiftType = sx* with a shiftValue of 0? + signext = decode_sign_ext64 (op.shiftType); + } if (sign && !signext) { signext = size; } From f986d0281b691670bdfb7db90749267b7a20f82b Mon Sep 17 00:00:00 2001 From: pancake Date: Wed, 23 Feb 2022 23:27:47 +0100 Subject: [PATCH 055/390] Fix DoS in kernelcache bin parser ##crash * Reported by lazymio * Reproducer z/rt/gwAAAEuAAB//wAAAACe2QEaAAAG+s8yAOH/AQAAAA== --- libr/bin/format/mach0/mach064_is_kernelcache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libr/bin/format/mach0/mach064_is_kernelcache.c b/libr/bin/format/mach0/mach064_is_kernelcache.c index f8f2c0eb56cf3..b2a3ecf12e960 100644 --- a/libr/bin/format/mach0/mach064_is_kernelcache.c +++ b/libr/bin/format/mach0/mach064_is_kernelcache.c @@ -1,3 +1,5 @@ +/* radare - LGPL - Copyright 2019-2022 - pancake, nibble */ + #include "mach0_defines.h" static bool is_kernelcache_buffer(RBuffer *b) { @@ -24,8 +26,7 @@ static bool is_kernelcache_buffer(RBuffer *b) { bool has_kext = false; ut32 cursor = sizeof (struct MACH0_(mach_header)); - for (i = 0; i < ncmds && cursor < length; i++) { - + for (i = 0; i < ncmds && cursor + 8 < length; i++) { ut32 cmdtype = r_buf_read_le32_at (b, cursor); ut32 cmdsize = r_buf_read_le32_at (b, cursor + 4); @@ -52,7 +53,6 @@ static bool is_kernelcache_buffer(RBuffer *b) { } break; } - cursor += cmdsize; } From 3ee2ef36c8b8b44378ff1bbe1f1caf7760de5c0f Mon Sep 17 00:00:00 2001 From: pancake Date: Wed, 23 Feb 2022 23:36:14 +0100 Subject: [PATCH 056/390] Fix large loading times in macho parser ##bin * Not really a DoS, but almost * Reported by lazymio * Reproducer: zvrt/gCd7QBMYWT6AAD6/2NiQGsOAAGbuAAAADQAAID7AAAAAAEAAAEBZWUgcmR4LCByY3gBHQAAABEAAAAB/wAA7wABAAFiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiY2JiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJi/3///2KdYmJidmJiZc767QIA/38BAAr/7n/WAc767QAAAgD2AB0AABAFAAAVAQAAAAHv7+/v7+/v7+/v729jYWwvc2hhcmUvcmFkYXJlMi9wZGJ4QAAAAAQAAAEBYmVxPwCQHckEAAAAANBEyQR6ABQAkETJBAAAAAAhAAAAAAIAAAAQAAIAAAAQEAAAEgAAAAEAAABlYXhAKysBAA== --- libr/bin/format/mach0/mach0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libr/bin/format/mach0/mach0.c b/libr/bin/format/mach0/mach0.c index 8313627507a5d..b7587f3ac2db4 100644 --- a/libr/bin/format/mach0/mach0.c +++ b/libr/bin/format/mach0/mach0.c @@ -1523,7 +1523,8 @@ static bool parse_chained_fixups(struct MACH0_(obj_t) *bin, ut32 offset, ut32 si bin->fixups_size = size; size_t i; ut64 cursor = starts_at + sizeof (ut32); - for (i = 0; i < segs_count; i++) { + ut64 bsize = r_buf_size (bin->b); + for (i = 0; i < segs_count && cursor + 4 < bsize; i++) { ut32 seg_off; if ((seg_off = r_buf_read_le32_at (bin->b, cursor)) == UT32_MAX || !seg_off) { cursor += sizeof (ut32); From d087e7f8165a8dc12f8dc868c81b6e68b950fb45 Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 24 Feb 2022 01:06:24 +0100 Subject: [PATCH 057/390] Update to the latest SDB from git (what will be 1.8.6) (#19750) * Fix some extern definitions in include files * Code cleanup ensuring casts everywhere * Now compiles as C++ --- shlr/sdb/Makefile | 9 ++- shlr/sdb/src/Makefile | 4 +- shlr/sdb/src/array.c | 28 ++++---- shlr/sdb/src/base64.c | 13 ++-- shlr/sdb/src/buffer.h | 33 ++++++--- shlr/sdb/src/cdb.c | 4 +- shlr/sdb/src/cdb.h | 8 +++ shlr/sdb/src/cdb_make.c | 8 +-- shlr/sdb/src/cdb_make.h | 10 +-- shlr/sdb/src/dict.c | 82 ++++------------------- shlr/sdb/src/diff.c | 12 ++-- shlr/sdb/src/disk.c | 7 +- shlr/sdb/src/fmt.c | 29 ++++---- shlr/sdb/src/{ht_inc.c => ht.inc} | 6 +- shlr/sdb/src/ht_inc.h | 10 ++- shlr/sdb/src/ht_pp.c | 4 +- shlr/sdb/src/ht_pp.h | 8 +++ shlr/sdb/src/ht_pu.c | 4 +- shlr/sdb/src/ht_pu.h | 8 +++ shlr/sdb/src/ht_up.c | 4 +- shlr/sdb/src/ht_up.h | 8 +++ shlr/sdb/src/ht_uu.c | 4 +- shlr/sdb/src/ht_uu.h | 8 +++ shlr/sdb/src/journal.c | 2 +- shlr/sdb/src/json.c | 14 ++-- shlr/sdb/src/json/api.c | 2 +- shlr/sdb/src/json/indent.c | 4 +- shlr/sdb/src/json/js0n.c | 2 + shlr/sdb/src/json/path.c | 6 +- shlr/sdb/src/json/rangstr.c | 29 +++----- shlr/sdb/src/lock.c | 4 +- shlr/sdb/src/ls.h | 26 +++++--- shlr/sdb/src/main.c | 34 +++++----- shlr/sdb/src/ns.c | 30 +++++---- shlr/sdb/src/query.c | 72 ++++++++++---------- shlr/sdb/src/sdb.c | 38 +++++------ shlr/sdb/src/sdbht.c | 10 +-- shlr/sdb/src/sdbht.h | 8 +++ shlr/sdb/src/set.c | 8 ++- shlr/sdb/src/set.h | 8 +++ shlr/sdb/src/text.c | 107 ++++++++++++++++-------------- shlr/sdb/src/types.h | 2 +- shlr/sdb/src/util.c | 4 +- 43 files changed, 377 insertions(+), 344 deletions(-) rename shlr/sdb/src/{ht_inc.c => ht.inc} (97%) diff --git a/shlr/sdb/Makefile b/shlr/sdb/Makefile index b3b4365fb4848..94f48ae2bb879 100644 --- a/shlr/sdb/Makefile +++ b/shlr/sdb/Makefile @@ -26,6 +26,13 @@ endif include wasi.mk +x xxx cxx: + # $(MAKE) CC="gcc -x c++ -Wall -fpermissive" + $(MAKE) CC=g++ CFLAGS="-fPIC -x c++ -Wall -fpermissive" + +o xo xoxo ox: + g++ -o sdb src/*.c -I src/ + wasi wasm: $(WASI_SDK) ${MAKE} src/sdb_version.h CC=$(WASI_CC) CFLAGS="$(WASI_CFLAGS)" $(MAKE) CC=$(WASI_CC) -C src all WITHPIC=0 @@ -40,7 +47,7 @@ asantest: asan: ${MAKE} src/sdb_version.h - CC=gcc CFLAGS="$(CFLAGS_ASAN)" ${MAKE} -C src all + CC=gcc LDFLAGS="$(CFLAGS_ASAN)" CFLAGS="$(CFLAGS_ASAN)" ${MAKE} -C src all pkgconfig: [ -d pkgconfig ] && ${MAKE} -C pkgconfig || true diff --git a/shlr/sdb/src/Makefile b/shlr/sdb/src/Makefile index 1e4fabebc7af9..6bd84f0f454c7 100644 --- a/shlr/sdb/src/Makefile +++ b/shlr/sdb/src/Makefile @@ -56,7 +56,7 @@ endif ifneq ($(SILENT),) @echo LIB libsdb${SOVER} endif - $(CC) ${CFLAGS} ${LDFLAGS} $(LDFLAGS_SHARED) -o $@ ${SOBJ} + $(CC) ${LDFLAGS} $(LDFLAGS_SHARED) -o $@ ${SOBJ} bin_deps: sdb_version.h $(MAKE) libsdb.a main.o @@ -65,7 +65,7 @@ bin $(BIN): bin_deps ifneq ($(SILENT),) @echo BIN ${BIN} endif - $(CC) ${CFLAGS} ${LDFLAGS} -o ${BIN} main.o ${OBJ} + $(CC) ${LDFLAGS} -o ${BIN} main.o ${OBJ} mrproper clean: rm -rf ${OBJ} ${SOBJ} main.o libsdb.a a.out ${BIN} sdb.dSYM diff --git a/shlr/sdb/src/array.c b/shlr/sdb/src/array.c index 92451aa6d5316..f3ed682568339 100644 --- a/shlr/sdb/src/array.c +++ b/shlr/sdb/src/array.c @@ -1,4 +1,4 @@ -/* sdb - MIT - Copyright 2011-2018 - pancake */ +/* sdb - MIT - Copyright 2011-2022 - pancake */ #include "sdb.h" #include @@ -97,12 +97,12 @@ SDB_API char *sdb_array_get(Sdb *s, const char *key, int idx, ut32 *cas) { idx = len - idx; } if (!idx) { - n = strchr (str, SDB_RS); + n = strchr ((char *)str, SDB_RS); if (!n) { return strdup (str); } len = n - str; - o = malloc (len + 1); + o = (char *)malloc (len + 1); if (!o) { return NULL; } @@ -111,16 +111,16 @@ SDB_API char *sdb_array_get(Sdb *s, const char *key, int idx, ut32 *cas) { return o; } for (i = 0; i < idx; i++) { - n = strchr (p, SDB_RS); + n = strchr ((char *)p, SDB_RS); if (!n) return NULL; p = n + 1; } - n = strchr (p, SDB_RS); + n = strchr ((char *)p, SDB_RS); if (!n) { return strdup (p); } len = n - p; - o = malloc (len + 1); + o = (char *)malloc (len + 1); if (o) { memcpy (o, p, len); o[len] = 0; @@ -157,7 +157,7 @@ SDB_API int sdb_array_insert(Sdb *s, const char *key, int idx, const char *val, if (SZT_ADD_OVFCHK (lval, lstr_tmp) || SZT_ADD_OVFCHK (lval + lstr_tmp, 2)) { return false; } - x = malloc (lval + lstr_tmp + 2); + x = (char *)malloc (lval + lstr_tmp + 2); if (!x) { return false; } @@ -171,7 +171,7 @@ SDB_API int sdb_array_insert(Sdb *s, const char *key, int idx, const char *val, x[lval] = SDB_RS; memcpy (x + lval + 1, str, lstr + 1); } else { - char *nstr = malloc (lstr + 1); + char *nstr = (char *)malloc (lstr + 1); if (!nstr) { free (x); return false; @@ -248,7 +248,7 @@ SDB_API int sdb_array_add_sorted(Sdb *s, const char *key, const char *val, ut32 if (i > 1) { qsort (vals, i, sizeof (ut64*), cstring_cmp); } - nstr_p = nstr = malloc (lstr + lval + 3); + nstr_p = nstr = (char *)malloc (lstr + lval + 3); if (!nstr) { return 1; } @@ -321,7 +321,7 @@ SDB_API bool sdb_array_append(Sdb *s, const char *key, const char *val, cas = kas; if (str && *str && str_len > 0) { int val_len = strlen (val); - char *newval = malloc (str_len + val_len + 2); + char *newval = (char *)malloc (str_len + val_len + 2); if (!newval) { return false; } @@ -359,7 +359,7 @@ SDB_API int sdb_array_set(Sdb *s, const char *key, int idx, const char *val, lval = strlen (val); if (idx > len) { int ret, i, ilen = idx-len; - char *newkey = malloc (ilen + lval + 1); + char *newkey = (char *)malloc (ilen + lval + 1); if (!newkey) { return 0; } @@ -375,7 +375,7 @@ SDB_API int sdb_array_set(Sdb *s, const char *key, int idx, const char *val, ptr = (char*)Aindexof (str, idx); if (ptr) { int diff = ptr - str; - char *nstr = malloc (lstr + lval + 2); + char *nstr = (char *)malloc (lstr + lval + 2); if (!nstr) { return false; } @@ -560,7 +560,7 @@ SDB_API bool sdb_array_prepend (Sdb *s, const char *key, const char *val, ut32 c cas = kas; if (str && *str) { int val_len = strlen (val); - char *newval = malloc (str_len + val_len + 2); + char *newval = (char *)malloc (str_len + val_len + 2); if (!newval) { return false; } @@ -694,7 +694,7 @@ SDB_API void sdb_array_sort_num(Sdb *s, const char *key, ut32 cas) { qsort (nums + 1, (int)*nums, sizeof (ut64), int_cmp); - nstr = malloc (*nums + 1); + nstr = (char *)malloc (*nums + 1); if (!nstr) { free (nums); return; diff --git a/shlr/sdb/src/base64.c b/shlr/sdb/src/base64.c index 7ebdb8cd86dff..e78d165cf404a 100644 --- a/shlr/sdb/src/base64.c +++ b/shlr/sdb/src/base64.c @@ -1,8 +1,5 @@ -/* base64 enc/dec - MIT - Copyright 2011-2016 - pancake */ +/* base64 enc/dec - MIT - Copyright 2011-2022 - pancake */ -#include -#include -#include #include "sdb.h" #define SZ 1024 @@ -71,7 +68,7 @@ SDB_API char *sdb_encode(const ut8 *bin, int len) { if (!len) { return strdup (""); } - out = calloc (8 + (len * 2), sizeof (char)); + out = (char *)calloc (8 + (len * 2), sizeof (char)); if (!out) { return NULL; } @@ -79,7 +76,7 @@ SDB_API char *sdb_encode(const ut8 *bin, int len) { return out; } -SDB_API ut8 *sdb_decode (const char *in, int *len) { +SDB_API ut8 *sdb_decode(const char *in, int *len) { ut8 *out; ut32 size; int olen, ilen; @@ -89,7 +86,7 @@ SDB_API ut8 *sdb_decode (const char *in, int *len) { if (!in) { return NULL; } - ilen = strlen (in); + ilen = (int)strlen (in); if (!ilen) { return NULL; } @@ -97,7 +94,7 @@ SDB_API ut8 *sdb_decode (const char *in, int *len) { if (size < (ut32)ilen) { return NULL; } - out = calloc (1, size); + out = (ut8 *)calloc (1, size); if (!out) { return NULL; } diff --git a/shlr/sdb/src/buffer.h b/shlr/sdb/src/buffer.h index 4fd4bf61fc1cb..e56012d4bc235 100644 --- a/shlr/sdb/src/buffer.h +++ b/shlr/sdb/src/buffer.h @@ -3,6 +3,10 @@ #include "types.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef int (*BufferOp)(int, const char *, int); typedef struct buffer { @@ -17,12 +21,12 @@ typedef struct buffer { #define BUFFER_INSIZE 8192 #define BUFFER_OUTSIZE 8192 -extern void buffer_init(buffer *,BufferOp,int,char *,unsigned int); +void buffer_init(buffer *,BufferOp,int,char *,unsigned int); -extern int buffer_flush(buffer *); -extern int buffer_put(buffer *,const char *,unsigned int); -extern int buffer_putalign(buffer *,const char *,unsigned int); -extern int buffer_putflush(buffer *,const char *,unsigned int); +int buffer_flush(buffer *); +int buffer_put(buffer *,const char *,unsigned int); +int buffer_putalign(buffer *,const char *,unsigned int); +int buffer_putflush(buffer *,const char *,unsigned int); #define buffer_PUTC(s,c) \ ( ((s)->n != (s)->p) \ @@ -30,12 +34,12 @@ extern int buffer_putflush(buffer *,const char *,unsigned int); : buffer_put((s),&(c),1) \ ) -extern int buffer_get(buffer *,char *,unsigned int); -extern int buffer_bget(buffer *,char *,unsigned int); -extern int buffer_feed(buffer *); +int buffer_get(buffer *,char *,unsigned int); +int buffer_bget(buffer *,char *,unsigned int); +int buffer_feed(buffer *); -extern char *buffer_peek(buffer *); -extern void buffer_seek(buffer *,unsigned int); +char *buffer_peek(buffer *); +void buffer_seek(buffer *,unsigned int); #define buffer_PEEK(s) ( (s)->x + (s)->n ) #define buffer_SEEK(s,len) ( ( (s)->p -= (len) ) , ( (s)->n += (len) ) ) @@ -46,12 +50,19 @@ extern void buffer_seek(buffer *,unsigned int); : buffer_get((s),(c),1) \ ) -extern int buffer_copy(buffer *,buffer *); +int buffer_copy(buffer *,buffer *); +// WTF GLOBALS +#if 0 extern buffer *buffer_0; extern buffer *buffer_0small; extern buffer *buffer_1; extern buffer *buffer_1small; extern buffer *buffer_2; +#endif + +#ifdef __cplusplus +} +#endif #endif diff --git a/shlr/sdb/src/cdb.c b/shlr/sdb/src/cdb.c index d0249e127d4ef..ed460872a44b4 100644 --- a/shlr/sdb/src/cdb.c +++ b/shlr/sdb/src/cdb.c @@ -1,7 +1,5 @@ /* Public domain - author D. J. Bernstein, modified by pancake - 2014-2016 */ -#include -#include #include #include "cdb.h" #if USE_MMAN @@ -54,7 +52,7 @@ bool cdb_init(struct cdb *c, int fd) { cdb_findstart (c); if (fd != -1 && !fstat (fd, &st) && st.st_size > 4 && st.st_size != (off_t)UT64_MAX) { #if USE_MMAN - char *x = mmap (0, st.st_size, PROT_READ, MAP_SHARED, fd, 0); + char *x = (char *)mmap (0, st.st_size, PROT_READ, MAP_SHARED, fd, 0); if (x == MAP_FAILED) { eprintf ("Cannot mmap %d\n", (int)st.st_size); return false; diff --git a/shlr/sdb/src/cdb.h b/shlr/sdb/src/cdb.h index b0d71d9ad631c..565530e8df02d 100644 --- a/shlr/sdb/src/cdb.h +++ b/shlr/sdb/src/cdb.h @@ -3,6 +3,10 @@ #ifndef CDB_H #define CDB_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include "types.h" @@ -36,4 +40,8 @@ int cdb_findnext(struct cdb *, ut32 u, const char *, ut32); #define cdb_datapos(c) ((c)->dpos) #define cdb_datalen(c) ((c)->dlen) +#ifdef __cplusplus +} +#endif + #endif diff --git a/shlr/sdb/src/cdb_make.c b/shlr/sdb/src/cdb_make.c index dd5c2a53c19ef..96b2f8d36b8cb 100644 --- a/shlr/sdb/src/cdb_make.c +++ b/shlr/sdb/src/cdb_make.c @@ -1,7 +1,5 @@ /* Public domain. */ -#include -#include #include "sdb.h" #include "cdb.h" #include "cdb_make.h" @@ -11,11 +9,11 @@ char *cdb_alloc(ut32 n) { #if __APPLE__ && !__POWERPC__ void *ret = NULL; - return posix_memalign (&ret, ALIGNMENT, n)? NULL: ret; + return (char *)posix_memalign (&ret, ALIGNMENT, n)? NULL: ret; #elif __SDB_WINDOWS__ && !__CYGWIN__ - return _aligned_malloc (n, ALIGNMENT); + return (char *)_aligned_malloc (n, ALIGNMENT); #else - return malloc (n); + return (char *)malloc (n); #endif } diff --git a/shlr/sdb/src/cdb_make.h b/shlr/sdb/src/cdb_make.h index 45c3c35925596..d226bcfa4cd21 100644 --- a/shlr/sdb/src/cdb_make.h +++ b/shlr/sdb/src/cdb_make.h @@ -31,10 +31,10 @@ struct cdb_make { int fd; }; -extern int cdb_make_start(struct cdb_make *,int); -extern int cdb_make_addbegin(struct cdb_make *,unsigned int,unsigned int); -extern int cdb_make_addend(struct cdb_make *,unsigned int,unsigned int,ut32); -extern int cdb_make_add(struct cdb_make *,const char *,unsigned int,const char *,unsigned int); -extern int cdb_make_finish(struct cdb_make *); +int cdb_make_start(struct cdb_make *, int); +int cdb_make_addbegin(struct cdb_make *, unsigned int, unsigned int); +int cdb_make_addend(struct cdb_make *, unsigned int, unsigned int,ut32); +int cdb_make_add(struct cdb_make *, const char *, unsigned int, const char *, unsigned int); +int cdb_make_finish(struct cdb_make *); #endif diff --git a/shlr/sdb/src/dict.c b/shlr/sdb/src/dict.c index d9d38fd1f7f15..d0bbdd595101e 100644 --- a/shlr/sdb/src/dict.c +++ b/shlr/sdb/src/dict.c @@ -1,12 +1,9 @@ -/* sdb - MIT - Copyright 2017 - pancake */ +/* sdb - MIT - Copyright 2017-2022 - pancake */ -#include -#include -#include #include "sdb.h" SDB_API dict *dict_new (ut32 size, dict_freecb f) { - dict *m = calloc (1, sizeof (dict)); + dict *m = (dict *)calloc (1, sizeof (dict)); if (!dict_init (m, R_MAX (size, 1), f)) { free (m); m = NULL; @@ -26,7 +23,7 @@ SDB_API bool dict_init (dict *m, ut32 size, dict_freecb f) { if (m) { memset (m, 0, sizeof (dict)); if (size > 0) { - m->table = calloc (size, sizeof (dictkv)); + m->table = (void **)calloc (size, sizeof (dictkv)); if (!m->table) { return false; } @@ -42,7 +39,7 @@ SDB_API void dict_fini (dict *m) { if (m) { if (m->f) { for (i = 0; i < m->size; i++) { - dictkv *kv = m->table[i]; + dictkv *kv = (dictkv *)m->table[i]; if (kv) { while (kv->k != MHTNO) { m->f (kv->u); @@ -76,9 +73,9 @@ SDB_API bool dict_set (dict *m, dicti k, dicti v, void *u) { return false; } const int bucket = dict_bucket (m, k); - dictkv *kv = m->table[bucket]; + dictkv *kv = (dictkv *)m->table[bucket]; if (!kv) { - kv = calloc (sizeof (dictkv), 2); + kv = (dictkv *)calloc (sizeof (dictkv), 2); if (kv) { m->table[bucket] = kv; kv->k = MHTNO; @@ -98,9 +95,10 @@ SDB_API bool dict_set (dict *m, dicti k, dicti v, void *u) { kv++; } int curln = (kv - tmp); - dictkv *newkv = realloc (tmp, (curln + 2) * sizeof (dictkv)); + dictkv *newkv = (dictkv *)realloc (tmp, (curln + 2) * sizeof (dictkv)); if (newkv) { - kv = m->table[bucket] = newkv; + kv = newkv; + m->table[bucket] = newkv; kv += curln; kv->k = k; kv->v = v; @@ -119,7 +117,7 @@ SDB_API void dict_stats (dict *m) { for (i = 0; i < m->size; i++) { printf ("%d: ", i); j = 0; - dictkv *kv = m->table[i]; + dictkv *kv = (dictkv *)m->table[i]; if (kv) { while (kv->k != MHTNO) { j++; @@ -135,7 +133,7 @@ SDB_API dictkv *dict_getr (dict *m, dicti k) { return NULL; } int bucket = dict_bucket (m, k); - dictkv *kv = m->table[bucket]; + dictkv *kv = (dictkv *)m->table[bucket]; if (kv) { while (kv->k != MHTNO) { if (kv->k == k) { @@ -168,14 +166,14 @@ SDB_API bool dict_del (dict *m, dicti k) { if (k == MHTNO) { return false; } - dictkv *kv = m->table[bucket]; + dictkv *kv = (dictkv *)m->table[bucket]; if (kv) { while (kv->k != MHTNO) { if (kv->k == k) { if (m->f) { m->f (kv->u); } - dictkv *n = kv + 1; + dictkv *n = (dictkv *)(kv + 1); while (n->k != MHTNO) { *kv++ = *n++; } @@ -198,7 +196,7 @@ SDB_API void dict_foreach (dict *m, dictkv_cb cb, void *u) { ut32 i; for (i = 0; i < m->size && iterate; i++) { - dictkv *kv = m->table[i]; + dictkv *kv = (dictkv *)m->table[i]; if (kv) { while (kv->k != MHTNO) { int res = cb (kv, u); @@ -211,55 +209,3 @@ SDB_API void dict_foreach (dict *m, dictkv_cb cb, void *u) { } } } - -#if 0 -static char *dict_str(dict *m, dicti k) { - // walk all buckets and print the data..... we need a printer for kv->u - char *res = malloc (1024); - int bucket = k % m->size; - dicti *kv = m->table[bucket]; - char *p = res; - for (i = 0; i < 1024; i++) { - sprintf (p, "%s%lld", comma, kv->v); - p += strlen (p); - kv++; - } - return res; -} - -static char *dict_str(dict *m) { - char *res = malloc (1024); - int bucket = k % m->size; - dicti *kv = m->table[bucket]; - int i; - char *p = res; - for (i = 0; i < m->size; i++) { - sprintf (p, "%s%lld", comma, kv->v); - p += strlen (p); - kv++; - } - return res; -} - -int main() { - dict m; - dict_init (&m, 2, free); - dict_set (&m, 0x100, 1, NULL); - dict_set (&m, 0x200, 2, NULL); - dict_set (&m, 0x300, 3, NULL); - dict_set (&m, 0x400, 4, NULL); -printf ("%d %d\n", (int)dict_get(&m, 0x100), (int)dict_get(&m, 0x200)); -printf ("%d %d\n", (int)dict_get(&m, 0x300), (int)dict_get(&m, 0x400)); -dict_stats(&m); - -#if 0 - dict_set(&m, dict_hash("username"), 1024, NULL); - dict_set(&m, 32, 212, strdup("test")); - dict_del(&m, dict_hash("username")); - printf ("%d\n", (int)dict_get(&m, dict_hash("username"))); - printf ("%s\n", dict_getu(&m, 32)); //dict_hash("username"))); -#endif - dict_fini(&m); - return 0; -} -#endif diff --git a/shlr/sdb/src/diff.c b/shlr/sdb/src/diff.c index 0b5549b482953..8da4ae025243a 100644 --- a/shlr/sdb/src/diff.c +++ b/shlr/sdb/src/diff.c @@ -24,7 +24,7 @@ SDB_API int sdb_diff_format(char *str, int size, const SdbDiff *diff) { SdbListIter *it; const char *component; - ls_foreach (diff->path, it, component) { + ls_foreach_cast (diff->path, it, const char *, component) { APPENDF ("%s/", component); } @@ -74,7 +74,7 @@ typedef struct sdb_diff_kv_cb_ctx { } SdbDiffKVCbCtx; static bool sdb_diff_report_kv_cb(void *user, const char *k, const char *v) { - const SdbDiffKVCbCtx *ctx = user; + const SdbDiffKVCbCtx *ctx = (const SdbDiffKVCbCtx *)user; sdb_diff_report_kv (ctx->ctx, k, v, ctx->add); return true; } @@ -85,7 +85,7 @@ static bool sdb_diff_report_kv_cb(void *user, const char *k, const char *v) { static void sdb_diff_report(SdbDiffCtx *ctx, Sdb *sdb, bool add) { SdbListIter *it; SdbNs *ns; - ls_foreach (sdb->ns, it, ns) { + ls_foreach_cast (sdb->ns, it, SdbNs*, ns) { sdb_diff_report_ns (ctx, ns, add); ls_push (ctx->path, ns->name); sdb_diff_report (ctx, ns->sdb, add); @@ -96,7 +96,7 @@ static void sdb_diff_report(SdbDiffCtx *ctx, Sdb *sdb, bool add) { } static bool sdb_diff_kv_cb(void *user, const char *k, const char *v) { - const SdbDiffKVCbCtx *ctx = user; + const SdbDiffKVCbCtx *ctx = (SdbDiffKVCbCtx *)user; Sdb *other = ctx->add ? ctx->ctx->a : ctx->ctx->b; const char *other_val = sdb_const_get (other, k, NULL); if (!other_val || !*other_val) { @@ -115,7 +115,7 @@ static bool sdb_diff_kv_cb(void *user, const char *k, const char *v) { static void sdb_diff_ctx(SdbDiffCtx *ctx) { SdbListIter *it; SdbNs *ns; - ls_foreach (ctx->a->ns, it, ns) { + ls_foreach_cast (ctx->a->ns, it, SdbNs*, ns) { Sdb *b_ns = sdb_ns (ctx->b, ns->name, false); if (!b_ns) { DIFF (ctx, @@ -136,7 +136,7 @@ static void sdb_diff_ctx(SdbDiffCtx *ctx) { ctx->a = a; ctx->b = b; } - ls_foreach (ctx->b->ns, it, ns) { + ls_foreach_cast (ctx->b->ns, it, SdbNs*, ns) { if (!sdb_ns (ctx->a, ns->name, false)) { DIFF (ctx, sdb_diff_report_ns (ctx, ns, true); diff --git a/shlr/sdb/src/disk.c b/shlr/sdb/src/disk.c index 4a5dfbf70b095..897611c22cf67 100644 --- a/shlr/sdb/src/disk.c +++ b/shlr/sdb/src/disk.c @@ -1,10 +1,7 @@ -/* sdb - MIT - Copyright 2013-2018 - pancake */ +/* sdb - MIT - Copyright 2013-2022 - pancake */ -#include #include #include -#include -#include #include #include "sdb.h" @@ -93,7 +90,7 @@ SDB_API bool sdb_disk_create(Sdb* s) { dir = s->dir ? s->dir : "./"; R_FREE (s->ndump); nlen = strlen (dir); - str = malloc (nlen + 5); + str = (char *)malloc (nlen + 5); if (!str) { return false; } diff --git a/shlr/sdb/src/fmt.c b/shlr/sdb/src/fmt.c index bc10964932eb6..ab6754dc4cdac 100644 --- a/shlr/sdb/src/fmt.c +++ b/shlr/sdb/src/fmt.c @@ -1,22 +1,21 @@ -/* sdb - MIT - Copyright 2014-2018 - pancake */ +/* sdb - MIT - Copyright 2014-2022 - pancake */ #include "sdb.h" -#include -#include // TODO: convert into a function // TODO: Add 'a' format for array of pointers null terminated?? // XXX SLOW CONCAT #define concat(x) if (x) { \ - int size = 2+strlen(x?x:"")+(out?strlen(out)+4:0); \ - if (out) { char *o = realloc (out, size); \ - if (o) {\ - strcat (o, ",");\ - strcat (o, x);\ - out = o;\ + int size = 2 + strlen (x? x: "")+(out? strlen (out) + 4: 0); \ + if (out) { \ + char *o = (char *)realloc (out, size); \ + if (o) { \ + strcat (o, ","); \ + strcat (o, x); \ + out = o; \ } \ - } else {\ - out = strdup (x);\ + } else { \ + out = strdup (x); \ } \ } @@ -145,12 +144,8 @@ SDB_API int sdb_fmt_init (void *p, const char *fmt) { } static const char *sdb_anext2(const char *str, const char **next) { - char *nxt, *p = strchr (str, SDB_RS); - if (p) { - nxt = p + 1; - } else { - nxt = NULL; - } + const char *p = strchr (str, SDB_RS); + const char *nxt = (p) ? p + 1: NULL; if (next) { *next = nxt; } diff --git a/shlr/sdb/src/ht_inc.c b/shlr/sdb/src/ht.inc similarity index 97% rename from shlr/sdb/src/ht_inc.c rename to shlr/sdb/src/ht.inc index f77bc880f4dca..03e1132a9c71b 100644 --- a/shlr/sdb/src/ht_inc.c +++ b/shlr/sdb/src/ht.inc @@ -99,14 +99,14 @@ static inline HT_(Kv) *next_kv(HtName_(Ht) *ht, HT_(Kv) *kv) { // pair_free - function for freeing a keyvaluepair - if NULL just does free. // calcsize - function to calculate the size of a value. if NULL, just stores 0. static HtName_(Ht)* internal_ht_new(ut32 size, ut32 prime_idx, HT_(Options) *opt) { - HtName_(Ht)* ht = calloc (1, sizeof (*ht)); + HtName_(Ht)* ht = (HtName_(Ht)*)calloc (1, sizeof (*ht)); if (!ht) { return NULL; } ht->size = size; ht->count = 0; ht->prime_idx = prime_idx; - ht->table = calloc (ht->size, sizeof (*ht->table)); + ht->table = (HT_(Bucket)*)calloc (ht->size, sizeof (*ht->table)); if (!ht->table) { free (ht); return NULL; @@ -201,7 +201,7 @@ static HT_(Kv) *reserve_kv(HtName_(Ht) *ht, const KEY_TYPE key, const int key_le } } - HT_(Kv) *newkvarr = realloc (bt->arr, (bt->count + 1) * ht->opt.elem_size); + HT_(Kv) *newkvarr = (HT_(Kv)*)realloc (bt->arr, (bt->count + 1) * ht->opt.elem_size); if (!newkvarr) { return NULL; } diff --git a/shlr/sdb/src/ht_inc.h b/shlr/sdb/src/ht_inc.h index 0df68f4adb75d..86ae08dca8f1a 100644 --- a/shlr/sdb/src/ht_inc.h +++ b/shlr/sdb/src/ht_inc.h @@ -1,4 +1,8 @@ -/* radare2 - BSD 3 Clause License - 2016-2021 - crowell */ +/* radare2 - BSD 3 Clause License - 2016-2022 - crowell, pancake */ + +#ifdef __cplusplus +extern "C" { +#endif #ifndef HT_TYPE #error HT_TYPE should be defined before including this header @@ -115,4 +119,8 @@ SDB_API void Ht_(foreach)(HtName_(Ht) *ht, HT_(ForeachCallback) cb, void *user); SDB_API HT_(Kv)* Ht_(find_kv)(HtName_(Ht)* ht, const KEY_TYPE key, bool* found); SDB_API bool Ht_(insert_kv)(HtName_(Ht) *ht, HT_(Kv) *kv, bool update); +#ifdef __cplusplus +} +#endif + #undef HT_TYPE diff --git a/shlr/sdb/src/ht_pp.c b/shlr/sdb/src/ht_pp.c index 09bbeb80d64e3..a5da5ede65852 100644 --- a/shlr/sdb/src/ht_pp.c +++ b/shlr/sdb/src/ht_pp.c @@ -1,6 +1,8 @@ +/* sdb - MIT - Copyright 2018-2022 - ret2libc, pancake */ + #include "sdb.h" #include "ht_pp.h" -#include "ht_inc.c" +#include "ht.inc" static HtName_(Ht)* internal_ht_default_new(ut32 size, ut32 prime_idx, HT_(DupValue) valdup, HT_(KvFreeFunc) pair_free, HT_(CalcSizeV) calcsizeV) { HT_(Options) opt = { diff --git a/shlr/sdb/src/ht_pp.h b/shlr/sdb/src/ht_pp.h index 0a92f4b8092e8..08ec5f08a4996 100644 --- a/shlr/sdb/src/ht_pp.h +++ b/shlr/sdb/src/ht_pp.h @@ -10,8 +10,16 @@ //#include "sdbht.h" #include "ht_inc.h" +#ifdef __cplusplus +extern "C" { +#endif + SDB_API HtName_(Ht)* Ht_(new0)(void); SDB_API HtName_(Ht)* Ht_(new)(HT_(DupValue) valdup, HT_(KvFreeFunc) pair_free, HT_(CalcSizeV) valueSize); SDB_API HtName_(Ht)* Ht_(new_size)(ut32 initial_size, HT_(DupValue) valdup, HT_(KvFreeFunc) pair_free, HT_(CalcSizeV) valueSize); +#ifdef __cplusplus +} +#endif + #endif diff --git a/shlr/sdb/src/ht_pu.c b/shlr/sdb/src/ht_pu.c index c21c8a66e5119..ffadecc5fda83 100644 --- a/shlr/sdb/src/ht_pu.c +++ b/shlr/sdb/src/ht_pu.c @@ -1,6 +1,8 @@ +/* sdb - MIT - Copyright 2018-2022 - ret2libc, pancake */ + #include "sdb.h" #include "ht_pu.h" -#include "ht_inc.c" +#include "ht.inc" static void free_kv_key(HT_(Kv) *kv) { free (kv->key); diff --git a/shlr/sdb/src/ht_pu.h b/shlr/sdb/src/ht_pu.h index cc7642f9174c7..28e0def3c33a2 100644 --- a/shlr/sdb/src/ht_pu.h +++ b/shlr/sdb/src/ht_pu.h @@ -8,7 +8,15 @@ #define HT_TYPE 4 #include "ht_inc.h" +#ifdef __cplusplus +extern "C" { +#endif + SDB_API HtName_(Ht)* Ht_(new0)(void); #undef HT_TYPE +#ifdef __cplusplus +} +#endif + #endif diff --git a/shlr/sdb/src/ht_up.c b/shlr/sdb/src/ht_up.c index 4f5de6672b3e6..9f167e81369bd 100644 --- a/shlr/sdb/src/ht_up.c +++ b/shlr/sdb/src/ht_up.c @@ -1,6 +1,8 @@ +/* sdb - MIT - Copyright 2018-2022 - ret2libc, pancake */ + #include "sdb.h" #include "ht_up.h" -#include "ht_inc.c" +#include "ht.inc" static HtName_(Ht)* internal_ht_default_new(ut32 size, ut32 prime_idx, HT_(DupValue) valdup, HT_(KvFreeFunc) pair_free, HT_(CalcSizeV) calcsizeV) { HT_(Options) opt = { diff --git a/shlr/sdb/src/ht_up.h b/shlr/sdb/src/ht_up.h index fdf5e15251505..0f084baf18a8b 100644 --- a/shlr/sdb/src/ht_up.h +++ b/shlr/sdb/src/ht_up.h @@ -10,9 +10,17 @@ #include "ht_inc.h" #include "sdbht.h" +#ifdef __cplusplus +extern "C" { +#endif + SDB_API HtName_(Ht)* Ht_(new0)(void); SDB_API HtName_(Ht)* Ht_(new)(HT_(DupValue) valdup, HT_(KvFreeFunc) pair_free, HT_(CalcSizeV) valueSize); SDB_API HtName_(Ht)* Ht_(new_size)(ut32 initial_size, HT_(DupValue) valdup, HT_(KvFreeFunc) pair_free, HT_(CalcSizeV) valueSize); #undef HT_TYPE +#ifdef __cplusplus +} +#endif + #endif diff --git a/shlr/sdb/src/ht_uu.c b/shlr/sdb/src/ht_uu.c index a8e0c9512afca..c2df1271aaa33 100644 --- a/shlr/sdb/src/ht_uu.c +++ b/shlr/sdb/src/ht_uu.c @@ -1,6 +1,8 @@ +/* sdb - MIT - Copyright 2018-2022 - ret2libc, pancake */ + #include "sdb.h" #include "ht_uu.h" -#include "ht_inc.c" +#include "ht.inc" // creates a default HtUU that has strings as keys SDB_API HtName_(Ht)* Ht_(new0)(void) { diff --git a/shlr/sdb/src/ht_uu.h b/shlr/sdb/src/ht_uu.h index 5e87f656908ef..bac103fbca740 100644 --- a/shlr/sdb/src/ht_uu.h +++ b/shlr/sdb/src/ht_uu.h @@ -10,6 +10,14 @@ #include "ht_inc.h" #include "sdbht.h" +#ifdef __cplusplus +extern "C" { +#endif + SDB_API HtName_(Ht)* Ht_(new0)(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/shlr/sdb/src/journal.c b/shlr/sdb/src/journal.c index 0c3542e445fde..fd5d9d206e086 100644 --- a/shlr/sdb/src/journal.c +++ b/shlr/sdb/src/journal.c @@ -62,7 +62,7 @@ SDB_API int sdb_journal_load(Sdb *s) { return 0; } lseek (fd, 0, SEEK_SET); - str = malloc (sz + 1); + str = (char *)malloc (sz + 1); if (!str) { return 0; } diff --git a/shlr/sdb/src/json.c b/shlr/sdb/src/json.c index da3672fe20193..f351918f403a0 100644 --- a/shlr/sdb/src/json.c +++ b/shlr/sdb/src/json.c @@ -120,7 +120,7 @@ SDB_API bool sdb_json_set(Sdb *s, const char *k, const char *p, const char *v, u if (!js) { const int v_len = strlen (v); const int p_len = strlen (p); - b = malloc (p_len + v_len + 8); + b = (char *)malloc (p_len + v_len + 8); if (b) { int is_str = isstring (v); const char *q = is_str? "\"": ""; @@ -146,7 +146,7 @@ SDB_API bool sdb_json_set(Sdb *s, const char *k, const char *p, const char *v, u // ensured to be positive by sdb_const_get_len // 7 corresponds to the length of '{"":"",' size_t buf_len = jslen + strlen (p) + strlen (v) + 7; - char *buf = malloc (buf_len); + char *buf = (char *)malloc (buf_len); if (buf) { int curlen, is_str = isstring (v); const char *quote = is_str ? "\"" : ""; @@ -188,7 +188,7 @@ SDB_API bool sdb_json_set(Sdb *s, const char *k, const char *p, const char *v, u if (msz < 1) { return false; } - str = malloc (msz); + str = (char *)malloc (msz); if (!str) { return false; } @@ -242,7 +242,7 @@ SDB_API bool sdb_json_set(Sdb *s, const char *k, const char *p, const char *v, u len[2]--; } - str = malloc (len[0] + len[2] + 1); + str = (char *)malloc (len[0] + len[2] + 1); if (!str) { return false; } @@ -264,7 +264,7 @@ SDB_API const char *sdb_json_format(SdbJsonString *s, const char *fmt, ...) { #define JSONSTR_ALLOCATE(y)\ if (s->len + y > s->blen) {\ s->blen *= 2;\ - x = realloc (s->buf, s->blen);\ + x = (char *)realloc (s->buf, s->blen);\ if (!x) {\ va_end (ap);\ return NULL;\ @@ -276,7 +276,7 @@ SDB_API const char *sdb_json_format(SdbJsonString *s, const char *fmt, ...) { } if (!s->buf) { s->blen = 1024; - s->buf = malloc (s->blen); + s->buf = (char *)malloc (s->blen); if (!s->buf) { return NULL; } @@ -307,7 +307,7 @@ SDB_API const char *sdb_json_format(SdbJsonString *s, const char *fmt, ...) { case 'l': JSONSTR_ALLOCATE (32); arg_l = va_arg (ap, ut64); - snprintf (tmp, sizeof (tmp), "0x%"ULLFMT "x", arg_l); + snprintf (tmp, sizeof (tmp), "0x%" ULLFMT "x", arg_l); memcpy (s->buf + s->len, tmp, strlen (tmp)); s->len += strlen (tmp); break; diff --git a/shlr/sdb/src/json/api.c b/shlr/sdb/src/json/api.c index 617f4c7d9e464..e2a5c86658e83 100644 --- a/shlr/sdb/src/json/api.c +++ b/shlr/sdb/src/json/api.c @@ -35,7 +35,7 @@ char *api_json_set (const char *s, const char *k, const char *v) { end[2] = s + strlen (s); len[2] = WLEN (2); - str = malloc (len[0]+len[1]+len[2]+1); + str = (char *)malloc (len[0]+len[1]+len[2]+1); if (!str) { return NULL; } diff --git a/shlr/sdb/src/json/indent.c b/shlr/sdb/src/json/indent.c index c3b544eafadc6..66af59346ee52 100644 --- a/shlr/sdb/src/json/indent.c +++ b/shlr/sdb/src/json/indent.c @@ -50,7 +50,7 @@ SDB_API char *sdb_json_indent(const char *s, const char *tab) { o_size += 2; indent = 0; - O = malloc (o_size + 1); + O = (char *)malloc (o_size + 1); if (!O) { return NULL; } @@ -110,7 +110,7 @@ SDB_API char *sdb_json_indent(const char *s, const char *tab) { SDB_API char *sdb_json_unindent(const char *s) { int instr = 0; int len = strlen (s); - char *o, *O = malloc (len + 1); + char *o, *O = (char *)malloc (len + 1); if (!O) { return NULL; } diff --git a/shlr/sdb/src/json/js0n.c b/shlr/sdb/src/json/js0n.c index fa1e61f56b3fa..6dac2fa18c50c 100644 --- a/shlr/sdb/src/json/js0n.c +++ b/shlr/sdb/src/json/js0n.c @@ -12,6 +12,8 @@ #define HAVE_COMPUTED_GOTOS 0 #elif __EMSCRIPTEN__ #define HAVE_COMPUTED_GOTOS 0 +#elif __cplusplus +#define HAVE_COMPUTED_GOTOS 0 #else #define HAVE_COMPUTED_GOTOS 1 #endif diff --git a/shlr/sdb/src/json/path.c b/shlr/sdb/src/json/path.c index ba42fd020a9bb..87e24cfb4451a 100644 --- a/shlr/sdb/src/json/path.c +++ b/shlr/sdb/src/json/path.c @@ -1,4 +1,4 @@ -/* sdb - MIT - Copyright 2012-2017 - pancake */ +/* sdb - MIT - Copyright 2012-2021 - pancake */ #include #include @@ -11,7 +11,7 @@ SDB_IPI void json_path_first(Rangstr *s) { if (!s->p) { return; } - p = strchr (s->p, '.'); + p = (char *)strchr (s->p, '.'); s->f = 0; s->t = p? (size_t)(p - s->p): strlen (s->p); } @@ -123,7 +123,7 @@ SDB_IPI Rangstr json_find (const char *s, Rangstr *rs) { len = strlen (s); if (len > RESFIXSZ) { - res = calloc (len + 1, sizeof (RangstrType)); + res = (RangstrType *)calloc (len + 1, sizeof (RangstrType)); if (!res) { eprintf ("Cannot allocate %d byte%s\n", len + 1, (len > 1)? "s": ""); diff --git a/shlr/sdb/src/json/rangstr.c b/shlr/sdb/src/json/rangstr.c index 656c5274f3ae3..d828757bfe4d1 100644 --- a/shlr/sdb/src/json/rangstr.c +++ b/shlr/sdb/src/json/rangstr.c @@ -1,4 +1,4 @@ -/* Copyleft 2012-2017 - sdb (aka SimpleDB) - pancake */ +/* Copyleft 2012-2022 - sdb - pancake */ #ifndef RANGSTR_C #define RANGSTR_C @@ -8,21 +8,12 @@ #include #include "rangstr.h" -#if 0 -SDB_IPI void rangstr_print (Rangstr *s) { - if (s && s->p) { - (void) fwrite (s->p+s->f, - s->t-s->f, 1, stdout); - } -} -#endif - SDB_IPI Rangstr rangstr_null(void) { Rangstr rs = {0, 0, 0, 0, 0}; return rs; } -SDB_IPI Rangstr rangstr_new (const char *s) { +SDB_IPI Rangstr rangstr_new(const char *s) { Rangstr rs; if (!s) { return rangstr_null (); @@ -35,14 +26,14 @@ SDB_IPI Rangstr rangstr_new (const char *s) { return rs; } -SDB_IPI int rangstr_length (Rangstr* rs) { +SDB_IPI int rangstr_length(Rangstr* rs) { if (rs->t > rs->f) { return rs->t - rs->f; } return 0; } -SDB_IPI int rangstr_int (Rangstr *s) { +SDB_IPI int rangstr_int(Rangstr *s) { if (!s || !s->p) { return 0; } @@ -70,12 +61,12 @@ SDB_IPI int rangstr_int (Rangstr *s) { return n * mul; } -SDB_IPI char *rangstr_dup (Rangstr *rs) { +SDB_IPI char *rangstr_dup(Rangstr *rs) { if (!rs->p) { return NULL; } int len = rangstr_length (rs); - char *p = malloc (len + 1); + char *p = (char *)malloc (len + 1); if (p) { memcpy (p, rs->p + rs->f, len); p[len] = 0; @@ -83,7 +74,7 @@ SDB_IPI char *rangstr_dup (Rangstr *rs) { return p; } -SDB_IPI Rangstr rangstr_news (const char *s, RangstrType *res, int i) { +SDB_IPI Rangstr rangstr_news(const char *s, RangstrType *res, int i) { Rangstr rs; rs.next = 1; rs.f = res[i]; @@ -93,7 +84,7 @@ SDB_IPI Rangstr rangstr_news (const char *s, RangstrType *res, int i) { return rs; } -SDB_IPI int rangstr_cmp (Rangstr *a, Rangstr *b) { +SDB_IPI int rangstr_cmp(Rangstr *a, Rangstr *b) { int la = a->t - a->f; int lb = b->t - b->f; int lbz = strlen (b->p + b->f); @@ -106,13 +97,13 @@ SDB_IPI int rangstr_cmp (Rangstr *a, Rangstr *b) { return memcmp (a->p + a->f, b->p + b->f, la); } -SDB_IPI int rangstr_find (Rangstr* a, char ch) { +SDB_IPI int rangstr_find(Rangstr* a, char ch) { size_t i = a->f; while (i < a->t && a->p[i] && a->p[i] != ch) i++; return (i < a->t && a->p[i]) ? (int) i: -1; } -SDB_IPI const char *rangstr_str (Rangstr* rs) { +SDB_IPI const char *rangstr_str(Rangstr* rs) { return rs->p + rs->f; } diff --git a/shlr/sdb/src/lock.c b/shlr/sdb/src/lock.c index 58acf07ee5f00..a9c4122662bc4 100644 --- a/shlr/sdb/src/lock.c +++ b/shlr/sdb/src/lock.c @@ -1,7 +1,5 @@ -/* sdb - MIT - Copyright 2012-2021 - pancake */ +/* sdb - MIT - Copyright 2012-2022 - pancake */ -#include -#include #include #include "sdb.h" #if __wasi__ || EMSCRIPTEN diff --git a/shlr/sdb/src/ls.h b/shlr/sdb/src/ls.h index 70e2e96ceb55b..742a4bbba0fff 100644 --- a/shlr/sdb/src/ls.h +++ b/shlr/sdb/src/ls.h @@ -4,6 +4,10 @@ #include #include "types.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef void (*SdbListFree)(void *ptr); typedef int (*SdbListComparator)(const void *a, const void *b); @@ -22,17 +26,19 @@ typedef struct ls_t { } SdbList; #define ls_foreach(list, it, pos) \ - if ((list)) \ - for (it = (list)->head; it && (pos = it->data); it = it->n) + if ((list)) for (it = (list)->head; it && (pos = it->data); it = it->n) + +#define ls_foreach_cast(list, it, T, pos) \ + if ((list)) for (it = (list)->head; it && (pos = (T)((it)->data)); it = (it)->n) + #define ls_foreach_safe(list, it, tmp, pos) \ - if ((list)) \ - for (it = list->head; \ - it && (pos = it->data) && ((tmp = it->n) || 1); it = tmp) + if ((list)) for (it = list->head; it && (pos = it->data) && ((tmp = it->n) || 1); it = tmp) + #define ls_foreach_prev(list, it, pos) \ - if ((list)) \ - for (it = list->tail; it && (pos = it->data); it = it->p) + if ((list)) for (it = list->tail; it && (pos = it->data); it = it->p) + +#define ls_iterator(x) ((x)? (x)->head: NULL) -#define ls_iterator(x) (x)?(x)->head:NULL // #define ls_empty(x) (!x || (!x->head && !x->tail)) #define ls_empty(x) (!x || !x->length) #define ls_head(x) x->head @@ -72,4 +78,8 @@ SDB_API int ls_del_n(SdbList *list, int n); SDB_API SdbListIter *ls_insert(SdbList *list, int n, void *data); SDB_API void *ls_pop_head(SdbList *list); +#ifdef __cplusplus +} +#endif + #endif diff --git a/shlr/sdb/src/main.c b/shlr/sdb/src/main.c index 0383cbb147adf..b3b573482fd0d 100644 --- a/shlr/sdb/src/main.c +++ b/shlr/sdb/src/main.c @@ -1,8 +1,6 @@ -/* sdb - MIT - Copyright 2011-2021 - pancake */ +/* sdb - MIT - Copyright 2011-2022 - pancake */ #include -#include -#include #include #ifndef HAVE_SYSTEM #define HAVE_SYSTEM 1 @@ -84,7 +82,7 @@ static char *slurp(FILE *f, size_t *sz) { /* run test/add10k.sh script to benchmark */ const int buf_size = 96096; - buf = calloc (1, buf_size); + buf = (char *)calloc (1, buf_size); if (!buf) { return NULL; } @@ -103,7 +101,7 @@ static char *slurp(FILE *f, size_t *sz) { buf[buf_len - 1] = '\0'; } - char *newbuf = realloc (buf, buf_len + 1); + char *newbuf = (char *)realloc (buf, buf_len + 1); // realloc behaves like free if buf_len is 0 if (!newbuf) { return buf; @@ -111,7 +109,7 @@ static char *slurp(FILE *f, size_t *sz) { return newbuf; } #endif - buf = calloc (BS + 1, 1); + buf = (char *)calloc (BS + 1, 1); if (!buf) { return NULL; } @@ -149,7 +147,7 @@ static char *slurp(FILE *f, size_t *sz) { int nlen = nl - buf; nextlen = len - nlen; if (nextlen > 0) { - next = malloc (nextlen + blocksize + 1); + next = (char *)malloc (nextlen + blocksize + 1); if (!next) { eprintf ("Cannot malloc %d\n", nextlen); break; @@ -169,7 +167,7 @@ static char *slurp(FILE *f, size_t *sz) { } #endif bufsize += blocksize; - tmp = realloc (buf, bufsize + 1); + tmp = (char *)realloc (buf, bufsize + 1); if (!tmp) { bufsize -= blocksize; break; @@ -239,7 +237,7 @@ static char* get_cname(const char*name) { } char *n = strdup (name); char *v, *d = n; - for (v=(char*)n; *v; v++) { + for (v = (char*)n; *v; v++) { if (*v == '/' || *v == '-') { *d++ = '_'; continue; @@ -254,7 +252,7 @@ static char* get_cname(const char*name) { } static char *escape(const char *b, int ch) { - char *a = calloc ((1 + strlen (b)), 4); + char *a = (char *)calloc ((1 + strlen (b)), 4); char *c = a; while (*b) { if (*b == ch) { @@ -293,7 +291,7 @@ static void sdb_dump_cb(MainOptions *mo, const char *k, const char *v, const cha if (!strcmp (v, "true") || !strcmp (v, "false")) { printf ("%s\"%s\":%s", comma, k, v); } else if (sdb_isnum (v)) { - printf ("%s\"%s\":%"ULLFMT"u", comma, k, sdb_atoi (v)); + printf ("%s\"%s\":%" ULLFMT "u", comma, k, sdb_atoi (v)); } else if (*v == '{' || *v == '[') { printf ("%s\"%s\":%s", comma, k, v); } else { @@ -325,7 +323,7 @@ static void sdb_dump_cb(MainOptions *mo, const char *k, const char *v, const cha static void cgen_header(MainOptions *mo, const char *cname) { if (mo->textmode) { - printf ("// SDB-CGEN V"SDB_VERSION"\n"); + printf ("// SDB-CGEN V" SDB_VERSION "\n"); printf ("// gcc -DMAIN=1 %s.c ; ./a.out > %s.h\n", cname, cname); printf ("#include \n"); printf ("#include \n"); @@ -391,7 +389,7 @@ static void cgen_footer(MainOptions *mo, const char *name, const char *cname) { return; } printf ("%%%%\n"); - printf ("// SDB-CGEN V"SDB_VERSION"\n"); + printf ("// SDB-CGEN V" SDB_VERSION "\n"); printf ("// %p\n", cname); printf ("typedef int (*GperfForeachCallback)(void *user, const char *k, const char *v);\n"); printf ("int gperf_%s_foreach(GperfForeachCallback cb, void *user) {\n", cname); @@ -491,7 +489,7 @@ static int sdb_dump(MainOptions *mo) { } SdbKv *kv; SdbListIter *it; - ls_foreach (l, it, kv) { + ls_foreach_cast (l, it, SdbKv*, kv) { const char *k = sdbkv_key (kv); const char *v = sdbkv_value (kv); if (v && *v && grep && !strstr (k, expgrep) && !strstr (v, expgrep)) { @@ -620,7 +618,7 @@ static int showusage(int o) { } static int showversion(void) { - printf ("sdb "SDB_VERSION "\n"); + printf ("sdb " SDB_VERSION "\n"); fflush (stdout); return 0; } @@ -687,7 +685,7 @@ static void dbdiff_cb(const SdbDiff *diff, void *user) { char *buf = sbuf; char *hbuf = NULL; if ((size_t)r >= sizeof (sbuf)) { - hbuf = malloc (r + 1); + hbuf = (char *)malloc (r + 1); if (!hbuf) { return; } @@ -741,12 +739,12 @@ static int sdb_system(const char *cmd) { static int gen_gperf(MainOptions *mo, const char *file, const char *name) { const size_t buf_size = 4096; - char *buf = malloc (buf_size); + char *buf = (char *)malloc (buf_size); if (!buf) { return -1; } size_t out_size = strlen (file) + 32; - char *out = malloc (out_size); + char *out = (char *)malloc (out_size); if (!out) { free (buf); return -1; diff --git a/shlr/sdb/src/ns.c b/shlr/sdb/src/ns.c index dc16f2607a0e3..44a14bd0f1c93 100644 --- a/shlr/sdb/src/ns.c +++ b/shlr/sdb/src/ns.c @@ -1,4 +1,4 @@ -/* sdb - MIT - Copyright 2011-2016 - pancake */ +/* sdb - MIT - Copyright 2011-2022 - pancake */ #include "sdb.h" @@ -7,8 +7,8 @@ SDB_API void sdb_ns_lock(Sdb *s, int lock, int depth) { SdbNs *ns; s->ns_lock = lock; if (depth) { // handles -1 as infinite - ls_foreach (s->ns, it, ns) { - sdb_ns_lock (ns->sdb, lock, depth-1); + ls_foreach_cast (s->ns, it, SdbNs*, ns) { + sdb_ns_lock (ns->sdb, lock, depth - 1); } } } @@ -16,10 +16,11 @@ SDB_API void sdb_ns_lock(Sdb *s, int lock, int depth) { static int in_list(SdbList *list, void *item) { SdbNs *ns; SdbListIter *it; - if (list && item) - ls_foreach (list, it, ns) { - if (item == ns) { - return 1; + if (list && item) { + ls_foreach_cast (list, it, SdbNs*, ns) { + if (item == ns) { + return 1; + } } } return 0; @@ -38,7 +39,7 @@ static void ns_free(Sdb *s, SdbList *list) { return; } ls_append (list, s); - ls_foreach (s->ns, it, ns) { + ls_foreach_cast (s->ns, it, SdbNs*, ns) { deleted = 0; next.n = it->n; if (!in_list (list, ns)) { @@ -98,7 +99,7 @@ static SdbNs *sdb_ns_new (Sdb *s, const char *name, ut32 hash) { } else { dir[0] = 0; } - ns = malloc (sizeof (SdbNs)); + ns = (SdbNs *)malloc (sizeof (SdbNs)); if (!ns) { return NULL; } @@ -130,7 +131,7 @@ SDB_API bool sdb_ns_unset(Sdb *s, const char *name, Sdb *r) { SdbNs *ns; SdbListIter *it; if (s && (name || r)) { - ls_foreach (s->ns, it, ns) { + ls_foreach_cast (s->ns, it, SdbNs*, ns) { if (name && (!strcmp (name, ns->name))) { ls_delete (s->ns, it); return true; @@ -151,7 +152,7 @@ SDB_API int sdb_ns_set(Sdb *s, const char *name, Sdb *r) { if (!s || !r || !name) { return 0; } - ls_foreach (s->ns, it, ns) { + ls_foreach_cast (s->ns, it, SdbNs*, ns) { if (ns->hash == hash) { if (ns->sdb == r) { return 0; @@ -189,7 +190,7 @@ SDB_API Sdb *sdb_ns(Sdb *s, const char *name, int create) { return NULL; } hash = sdb_hash (name); - ls_foreach (s->ns, it, ns) { + ls_foreach_cast (s->ns, it, SdbNs*, ns) { if (ns->hash == hash) { return ns->sdb; } @@ -212,8 +213,9 @@ SDB_API Sdb *sdb_ns_path(Sdb *s, const char *path, int create) { char *ptr, *str; char *slash; - if (!s || !path || !*path) + if (!s || !path || !*path) { return s; + } ptr = str = strdup (path); do { slash = strchr (ptr, '/'); @@ -231,7 +233,7 @@ SDB_API Sdb *sdb_ns_path(Sdb *s, const char *path, int create) { static void ns_sync(Sdb *s, SdbList *list) { SdbNs *ns; SdbListIter *it; - ls_foreach (s->ns, it, ns) { + ls_foreach_cast (s->ns, it, SdbNs*, ns) { if (in_list (list, ns)) { continue; } diff --git a/shlr/sdb/src/query.c b/shlr/sdb/src/query.c index afd9eba08e2a3..05170c201e077 100644 --- a/shlr/sdb/src/query.c +++ b/shlr/sdb/src/query.c @@ -1,10 +1,7 @@ /* sdb - MIT - Copyright 2011-2022 - pancake */ -#include -#include -#include -#include #include +#include #include #include "sdb.h" @@ -15,7 +12,7 @@ typedef struct { } StrBuf; static StrBuf* strbuf_new(void) { - return calloc (sizeof (StrBuf), 1); + return (StrBuf*) calloc (sizeof (StrBuf), 1); } #define NEWLINE_AFTER_QUERY 1 @@ -27,7 +24,7 @@ static StrBuf* strbuf_append(StrBuf *sb, const char *str, const int nl) { int len = strlen (str); if ((sb->len + len + 2) >= sb->size) { int newsize = sb->size + len + 256; - char *b = realloc (sb->buf, newsize); + char *b = (char *)realloc (sb->buf, newsize); /// TODO perform free and force all callers to update the ref? if (!b) { return NULL; @@ -90,8 +87,9 @@ typedef struct { } ForeachListUser; static bool foreach_list_cb(void *user, const char *k, const char *v) { - ForeachListUser *rlu = user; - char *line, *root; + ForeachListUser *rlu = (ForeachListUser*)user; + char *line = NULL; + char *root = NULL; int rlen, klen, vlen; ut8 *v2 = NULL; if (!rlu) { @@ -108,7 +106,7 @@ static bool foreach_list_cb(void *user, const char *k, const char *v) { vlen = strlen (v); if (root) { rlen = strlen (root); - line = malloc (klen + vlen + rlen + 3); + line = (char *)malloc (klen + vlen + rlen + 3); if (!line) { free (v2); return false; @@ -119,7 +117,7 @@ static bool foreach_list_cb(void *user, const char *k, const char *v) { line[rlen + klen + 1] = '='; memcpy (line + rlen + klen + 2, v, vlen + 1); } else { - line = malloc (klen + vlen + 2); + line = (char *)malloc (klen + vlen + 2); if (!line) { free (v2); return false; @@ -147,7 +145,7 @@ static void walk_namespace(StrBuf *sb, char *root, int left, char *p, SdbNs *ns, sdb_foreach (ns->sdb, foreach_list_cb, &user); /*Pick "sub"-ns*/ - ls_foreach (ns->sdb->ns, it, n) { + ls_foreach_cast (ns->sdb->ns, it, SdbNs*, n) { len = strlen (n->name); p[0] = '/'; if (len + 2 < left) { @@ -174,7 +172,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { StrBuf *out = strbuf_new (); if ((int)len < 1 || !buf) { bufset = true; - buf = malloc ((len = 64)); + buf = (char *)malloc ((len = 64)); if (!buf) { strbuf_free (out); return NULL; @@ -209,7 +207,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { if (*p == '#') { char buffer[16]; p++; - next = strchr (p, ';'); + next = (char *)strchr (p, ';'); if (next) { *next = 0; } @@ -226,12 +224,12 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { p++; } if (next) *next = ';'; - eq = strchr (p, '='); + eq = (char *)strchr (p, '='); if (eq) { d = 1; *eq++ = 0; if (*eq == '$') { - next = strchr (eq + 1, ';'); + next = (char *)strchr (eq + 1, ';'); if (next) *next = 0; val = sdb_const_get (s, eq + 1, 0); if (!val) { @@ -248,7 +246,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { d = 0; } if (!is_ref) { - next = strchr (val? val: cmd, ';'); + next = (char *)strchr (val? val: cmd, ';'); } //if (!val) val = eq; if (!is_ref && val && *val == '"') { @@ -256,7 +254,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { // TODO: escape \" too quot = (char*)val; next_quote: - quot = strchr (quot, '"'); + quot = (char *)strchr (quot, '"'); if (quot) { if (*(quot - 1) == '\\') { memmove (quot - 1, quot, strlen (quot) + 1); @@ -298,7 +296,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { char root[1024]; // limit namespace length? SdbListIter *it; SdbNs *ns; - ls_foreach (s->ns, it, ns) { + ls_foreach_cast (s->ns, it, SdbNs*, ns) { int name_len = strlen (ns->name); if (name_len < (long)sizeof (root)) { memcpy (root, ns->name, name_len + 1); @@ -314,7 +312,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { if (!strcmp (cmd, "**")) { SdbListIter *it; SdbNs *ns; - ls_foreach (s->ns, it, ns) { + ls_foreach_cast (s->ns, it, SdbNs*, ns) { out_concat (ns->name); } goto fail; @@ -324,7 +322,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { SdbList *list = sdb_foreach_list (s, true); SdbListIter *iter; SdbKv *kv; - ls_foreach (list, iter, kv) { + ls_foreach_cast (list, iter, SdbKv*, kv) { foreach_list_cb (&user, sdbkv_key (kv), sdbkv_value (kv)); } ls_free (list); @@ -364,7 +362,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { SdbKv *kv; SdbListIter *li; SdbList *l = sdb_foreach_match (s, cmd + 2, false); - ls_foreach (l, li, kv) { + ls_foreach_cast (l, li, SdbKv*, kv) { strbuf_append (out, sdbkv_key (kv), 0); strbuf_append (out, "=", 0); strbuf_append (out, sdbkv_value (kv), 1); @@ -378,7 +376,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { } else if (*cmd == '+' || *cmd == '-') { d = 1; if (!buf) { - buf = calloc (1, len); + buf = (char *)calloc (1, len); if (!buf) { goto fail; } @@ -467,30 +465,30 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { } // keep base if (base == 16) { - w = snprintf (buf, len - 1, "0x%"ULLFMT"x", n); + w = snprintf (buf, len - 1, "0x%" ULLFMT "x", n); if (w < 0 || (size_t)w > len) { if (bufset && len < 0xff) { free (buf); - buf = malloc (len = 0xff); + buf = (char *)malloc (len = 0xff); if (!buf) { goto fail; } } bufset = true; - snprintf (buf, 0xff, "0x%"ULLFMT"x", n); + snprintf (buf, 0xff, "0x%" ULLFMT "x", n); } } else { - w = snprintf (buf, len-1, "%"ULLFMT"d", n); + w = snprintf (buf, len-1, "%" ULLFMT "d", n); if (w < 0 || (size_t)w > len) { if (bufset && len < 0xff) { free (buf); - buf = malloc (len = 0xff); + buf = (char *)malloc (len = 0xff); if (!buf) { goto fail; } } bufset = true; - snprintf (buf, 0xff, "%"ULLFMT"d", n); + snprintf (buf, 0xff, "%" ULLFMT "d", n); } } } @@ -501,7 +499,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { // if (!eq) ... alength = sdb_array_length (s, p); if (!buf) { - buf = malloc (++len); + buf = (char *)malloc (++len); if (!buf) { goto fail; } @@ -512,7 +510,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { if (bufset) { free (buf); } - buf = malloc (len = 32); + buf = (char *)malloc (len = 32); bufset = 1; snprintf (buf, 31, "%d", alength); } @@ -602,7 +600,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { char *tmp = sdb_array_get (s, p, -i, NULL); if (tmp) { if (encode) { - char *newtmp = (void*)sdb_decode (tmp, NULL); + char *newtmp = (char*)sdb_decode (tmp, NULL); if (!newtmp) { goto fail; } @@ -691,7 +689,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { len = strlen (buf) + 1; } if (encode) { - char *newbuf = (void*)sdb_decode (buf, NULL); + char *newbuf = (char*)sdb_decode (buf, NULL); if (newbuf) { free (buf); buf = newbuf; @@ -705,7 +703,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { } wl = strlen (sval); if (!buf || wl >= len) { - buf = malloc (wl + 2); + buf = (char *)malloc (wl + 2); if (!buf) { free (out->buf); out->buf = NULL; @@ -724,7 +722,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { } buf[i] = 0; if (encode) { - char *newbuf = (void*)sdb_decode (buf, NULL); + char *newbuf = (char*)sdb_decode (buf, NULL); if (newbuf) { if (bufset) { free (buf); @@ -778,7 +776,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { // TODO: not optimized to reuse 'buf' if ((tmp = sdb_json_get (s, cmd, json, 0))) { if (encode) { - char *newtmp = (void*)sdb_decode (tmp, NULL); + char *newtmp = (char*)sdb_decode (tmp, NULL); if (!newtmp) goto fail; free (tmp); @@ -797,7 +795,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { // sdbget if ((q = sdb_const_get (s, cmd, 0))) { if (encode) { - q = (void*)sdb_decode (q, NULL); + q = (char*)sdb_decode (q, NULL); } out_concat (q); if (encode) { @@ -890,7 +888,7 @@ static char *slurp(const char *file) { return NULL; } lseek (fd, 0, SEEK_SET); - char *text = malloc (sz + 1); + char *text = (char *)malloc (sz + 1); if (!text) { close (fd); return NULL; diff --git a/shlr/sdb/src/sdb.c b/shlr/sdb/src/sdb.c index 51ff1586e3d18..235dea9a93b35 100644 --- a/shlr/sdb/src/sdb.c +++ b/shlr/sdb/src/sdb.c @@ -1,10 +1,7 @@ /* sdb - MIT - Copyright 2011-2022 - pancake */ -#include #include #include -#include -#include #include #include "sdb.h" @@ -62,7 +59,7 @@ SDB_API Sdb* sdb_new(const char *path, const char *name, int lock) { if (path && *path) { size_t plen = strlen (path); size_t nlen = strlen (name); - s->dir = malloc (plen + nlen + 2); + s->dir = (char *)malloc (plen + nlen + 2); if (!s->dir) { free (s); return NULL; @@ -144,7 +141,7 @@ SDB_API void sdb_file(Sdb* s, const char *dir) { } static bool sdb_merge_cb(void *user, const char *k, const char *v) { - sdb_set (user, k, v, 0); + sdb_set ((Sdb*)user, k, v, 0); return true; } @@ -355,7 +352,7 @@ SDB_API int sdb_concat(Sdb *s, const char *key, const char *value, ut32 cas) { return sdb_set (s, key, value, cas); } vl = strlen (value); - o = malloc (kl + vl + 1); + o = (char *)malloc (kl + vl + 1); if (o) { memcpy (o, p, kl); memcpy (o + kl, value, vl + 1); @@ -583,7 +580,7 @@ static ut32 sdb_set_internal(Sdb* s, const char *key, char *val, bool owned, ut3 if (owned) { val = strdup (""); } else { - val = ""; + val = (char *)""; } } // XXX strlen computed twice.. because of check_*() @@ -672,7 +669,8 @@ static bool sdb_foreach_list_cb(void *user, const char *k, const char *v) { } static int __cmp_asc(const void *a, const void *b) { - const SdbKv *ka = a, *kb = b; + const SdbKv *ka = (SdbKv *)a; + const SdbKv *kb = (SdbKv *)b; return strcmp (sdbkv_key (ka), sdbkv_key (kb)); } @@ -737,7 +735,9 @@ typedef struct { static bool sdb_foreach_match_cb(void *user, const char *k, const char *v) { _match_sdb_user *o = (_match_sdb_user*)user; - SdbKv tkv = { .base.key = (char*)k, .base.value = (char*)v }; + SdbKv tkv = {0}; + tkv.base.key = (char *)k; + tkv.base.value = (char *)v; if (sdbkv_match (&tkv, o->expr)) { SdbKv *kv = R_NEW0 (SdbKv); kv->base.key = strdup (k); @@ -966,7 +966,7 @@ SDB_API bool sdb_dump_dupnext(Sdb* s, char *key, char **value, int *_vlen) { if (value) { *value = 0; if (vlen < SDB_MAX_VALUE) { - *value = malloc (vlen + 10); + *value = (char *)malloc (vlen + 10); if (!*value) { return false; } @@ -1021,7 +1021,7 @@ SDB_API bool sdb_expire_set(Sdb* s, const char *key, ut64 expire, ut32 cas) { if (len < 1 || len >= INT32_MAX) { return false; } - if (!(buf = calloc (1, len + 1))) { + if (!(buf = (char *)calloc (1, len + 1))) { return false; } cdb_read (&s->db, buf, len, pos); @@ -1047,7 +1047,7 @@ SDB_API bool sdb_hook(Sdb* s, SdbHook cb, void* user) { SdbHook hook; SdbListIter *iter; if (s->hooks) { - ls_foreach (s->hooks, iter, hook) { + ls_foreach_cast (s->hooks, iter, SdbHook, hook) { if (!(i % 2) && (hook == cb)) { return false; } @@ -1066,7 +1066,7 @@ SDB_API bool sdb_unhook(Sdb* s, SdbHook h) { int i = 0; SdbHook hook; SdbListIter *iter, *iter2; - ls_foreach (s->hooks, iter, hook) { + ls_foreach_cast (s->hooks, iter, SdbHook, hook) { if (!(i % 2) && (hook == h)) { iter2 = iter->n; ls_delete (s->hooks, iter); @@ -1085,7 +1085,7 @@ SDB_API int sdb_hook_call(Sdb *s, const char *k, const char *v) { if (s->timestamped && s->last) { s->last = sdb_now (); } - ls_foreach (s->hooks, iter, hook) { + ls_foreach_cast (s->hooks, iter, SdbHook, hook) { if (!(i % 2) && k && iter->n) { void *u = iter->n->data; hook (s, u, k, v); @@ -1138,7 +1138,7 @@ SDB_API void sdb_drain(Sdb *s, Sdb *f) { } static bool copy_foreach_cb(void *user, const char *k, const char *v) { - Sdb *dst = user; + Sdb *dst = (Sdb *)user; sdb_set (dst, k, v, 0); return true; } @@ -1147,7 +1147,7 @@ SDB_API void sdb_copy(Sdb *src, Sdb *dst) { sdb_foreach (src, copy_foreach_cb, dst); SdbListIter *it; SdbNs *ns; - ls_foreach (src->ns, it, ns) { + ls_foreach_cast (src->ns, it, SdbNs*, ns) { sdb_copy (ns->sdb, sdb_ns (dst, ns->name, true)); } } @@ -1158,7 +1158,7 @@ typedef struct { } UnsetCallbackData; static bool unset_cb(void *user, const char *k, const char *v) { - UnsetCallbackData *ucd = user; + UnsetCallbackData *ucd = (UnsetCallbackData *)user; if (sdb_match (k, ucd->key)) { sdb_unset (ucd->sdb, k, 0); } @@ -1181,7 +1181,7 @@ typedef struct { } LikeCallbackData; static bool like_cb(void *user, const char *k, const char *v) { - LikeCallbackData *lcd = user; + LikeCallbackData *lcd = (LikeCallbackData *)user; if (!user) { return false; } @@ -1227,7 +1227,7 @@ SDB_API char** sdb_like(Sdb *s, const char *k, const char *v, SdbForeachCallback lcd.val = NULL; } lcd.array_size = sizeof (char*) * 2; - lcd.array = calloc (lcd.array_size, 1); + lcd.array = (const char **)calloc (lcd.array_size, 1); // XXX shouldnt be const if (!lcd.array) { return NULL; } diff --git a/shlr/sdb/src/sdbht.c b/shlr/sdb/src/sdbht.c index 969ef1da2f3f1..4f216cf422f3e 100644 --- a/shlr/sdb/src/sdbht.c +++ b/shlr/sdb/src/sdbht.c @@ -1,4 +1,4 @@ -/* sdb - MIT - Copyright 2011-2020 - pancake */ +/* sdb - MIT - Copyright 2011-2022 - pancake */ #include "sdbht.h" @@ -20,16 +20,16 @@ static bool sdb_ht_internal_insert(HtPP* ht, const char* key, const char* value, return false; } SdbKv kvp = {{ 0 }}; - kvp.base.key = strdup ((void *)key); + kvp.base.key = strdup (key); if (!kvp.base.key) { goto err; } - kvp.base.value = strdup ((void *)value); + kvp.base.value = strdup (value); if (!kvp.base.value) { goto err; } - kvp.base.key_len = strlen (kvp.base.key); - kvp.base.value_len = strlen (kvp.base.value); + kvp.base.key_len = strlen ((const char *)kvp.base.key); + kvp.base.value_len = strlen ((const char *)kvp.base.value); kvp.expire = 0; return ht_pp_insert_kv (ht, (HtPPKv*)&kvp, update); diff --git a/shlr/sdb/src/sdbht.h b/shlr/sdb/src/sdbht.h index 6e8da125680e7..5bc54ea9043b3 100644 --- a/shlr/sdb/src/sdbht.h +++ b/shlr/sdb/src/sdbht.h @@ -3,6 +3,10 @@ #include "ht_pp.h" +#ifdef __cplusplus +extern "C" { +#endif + /** keyvalue pair **/ typedef struct sdb_kv { //sub of HtPPKv so we can cast safely @@ -49,4 +53,8 @@ SDB_API char* sdb_ht_find(HtPP* ht, const char* key, bool* found); // Find the KeyValuePair corresponding to the matching key. SDB_API SdbKv* sdb_ht_find_kvp(HtPP* ht, const char* key, bool* found); +#ifdef __cplusplus +} +#endif + #endif // __SDB_HT_H diff --git a/shlr/sdb/src/set.c b/shlr/sdb/src/set.c index 09704e76caab4..f57821194e3bf 100644 --- a/shlr/sdb/src/set.c +++ b/shlr/sdb/src/set.c @@ -15,7 +15,9 @@ static bool u_foreach_cb(void *user, const ut64 k, const void *nada) { } SDB_API void set_u_foreach(SetU *s, set_u_foreach_cb cb, void *userdata) { - SetData sd = {cb, userdata}; + SetData sd; + sd.cbptr = (void *)cb; + sd.userdata = (void *)userdata; ht_up_foreach (s, u_foreach_cb, &sd); } @@ -26,7 +28,9 @@ static bool p_foreach_cb(void *user, const void *k, const void *nada) { } SDB_API void set_p_foreach(SetP *s, set_p_foreach_cb cb, void *userdata) { - SetData sd = {cb, userdata}; + SetData sd; + sd.cbptr = (void *)cb; + sd.userdata = (void *)userdata; ht_pp_foreach (s, p_foreach_cb, &sd); } //// diff --git a/shlr/sdb/src/set.h b/shlr/sdb/src/set.h index 6f9d2d00301e3..7202a59e5795e 100644 --- a/shlr/sdb/src/set.h +++ b/shlr/sdb/src/set.h @@ -4,6 +4,10 @@ #include "ht_pp.h" #include "ht_up.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef HtPP SetP; typedef bool (*set_p_foreach_cb)(void *userdata, const void *p); typedef bool (*set_u_foreach_cb)(void *userdata, const ut64 u); @@ -25,4 +29,8 @@ SDB_API void set_u_free(SetU *p); SDB_API void set_u_foreach(SetU *s, set_u_foreach_cb cb, void *u); +#ifdef __cplusplus +} +#endif + #endif diff --git a/shlr/sdb/src/text.c b/shlr/sdb/src/text.c index 707e926e07a0a..5165e5198b1fc 100644 --- a/shlr/sdb/src/text.c +++ b/shlr/sdb/src/text.c @@ -1,4 +1,4 @@ -/* sdb - MIT - Copyright 2020-2021 - thestr4ng3r */ +/* sdb - MIT - Copyright 2020-2022 - pancake, thestr4ng3r */ #include "sdb.h" @@ -60,31 +60,54 @@ */ static int cmp_ns(const void *a, const void *b) { - const SdbNs *nsa = a; - const SdbNs *cia = b; + const SdbNs *nsa = (const SdbNs *)a; + const SdbNs *cia = (const SdbNs *)b; return strcmp (nsa->name, cia->name); } + // n = position we are currently looking at // p = position until we have already written everything // flush a block of text that doesn't have to be escaped -#define FLUSH do { if (p != n) { (void)write (fd, p, n - p); p = n; } } while (0) -// write and escape a string from str to fd -#define ESCAPE_LOOP(fd, str, escapes) do { \ - const char *p = str; \ - const char *n = p; \ - while (*n) { \ - switch (*n) { escapes } \ - n++; \ - } \ - FLUSH; \ - } while (0) -#define ESCAPE(c, repl, replsz) \ - case c: \ - FLUSH; \ - p++; \ - if (write (fd, "\\"repl, replsz + 1) != replsz + 1) { return false; }; \ + +static bool escape_flush(int fd, const char *p, const char *n) { + if (p != n && write (fd, p, n - p) != n - p) { + return false; + } + return true; +} + +static bool escape_loop(int fd, const char *str, char ch) { + const char *p = str; + const char *n = p; + bool ok = true; + while (*n && ok) { + ok = true; + switch (*n) { + case '\\': + ok = escape_flush (fd, p, n) && write (fd, "\\\\", 2) == 2; + p = n + 1; + break; + case '\r': + ok = escape_flush (fd, p, n) && write (fd, "\\r", 2) == 2; + p = n + 1; + break; + case '\n': + ok = escape_flush (fd, p, n) && write (fd, "\\n", 2) == 2; + p = n + 1; break; + default: + if (ch && *n == ch) { + char pair[2] = { '\\', ch }; + ok = escape_flush (fd, p, n) && write (fd, &pair, 2) == 2; + p = n + 1; + } + break; + } + n++; + } + return ok && escape_flush (fd, p, n); +} static bool write_path(int fd, SdbList *path) { if (write (fd, "/", 1) != 1) { // always print a /, even if path is empty @@ -93,7 +116,7 @@ static bool write_path(int fd, SdbList *path) { SdbListIter *it; const char *path_token; bool first = true; - ls_foreach (path, it, path_token) { + ls_foreach_cast (path, it, const char *, path_token) { if (first) { first = false; } else { @@ -101,12 +124,9 @@ static bool write_path(int fd, SdbList *path) { return false; } } - ESCAPE_LOOP (fd, path_token, - ESCAPE ('\\', "\\", 1); - ESCAPE ('/', "/", 1); - ESCAPE ('\n', "n", 1); - ESCAPE ('\r', "r", 1); - ); + if (!escape_loop (fd, path_token, '/')) { + return false; + } } return true; } @@ -118,29 +138,15 @@ static bool write_key(int fd, const char *k) { return false; } } - ESCAPE_LOOP (fd, k, - ESCAPE ('\\', "\\", 1); - ESCAPE ('=', "=", 1); - ESCAPE ('\n', "n", 1); - ESCAPE ('\r', "r", 1); - ); - return true; + return escape_loop (fd, k, '='); } static bool write_value(int fd, const char *v) { - ESCAPE_LOOP (fd, v, - ESCAPE ('\\', "\\", 1); - ESCAPE ('\n', "n", 1); - ESCAPE ('\r', "r", 1); - ); - return true; + return escape_loop (fd, v, 0); } -#undef FLUSH -#undef ESCAPE_LOOP -#undef ESCAPE static bool save_kv_cb(void *user, const char *k, const char *v) { - int fd = *(int *)user; + int fd = *((int *)user); if (!write_key (fd, k) || write (fd, "=", 1) != 1) { return false; } @@ -161,7 +167,7 @@ static bool text_save(Sdb *s, int fd, bool sort, SdbList *path) { SdbList *l = sdb_foreach_list (s, true); SdbKv *kv; SdbListIter *it; - ls_foreach (l, it, kv) { + ls_foreach_cast (l, it, SdbKv*, kv) { save_kv_cb (&fd, sdbkv_key (kv), sdbkv_value (kv)); } ls_free (l); @@ -178,7 +184,7 @@ static bool text_save(Sdb *s, int fd, bool sort, SdbList *path) { } SdbNs *ns; SdbListIter *it; - ls_foreach (l, it, ns) { + ls_foreach_cast (l, it, SdbNs*, ns) { if (write (fd, "\n", 1) != 1) { ls_free (l); return false; @@ -249,7 +255,7 @@ static void load_process_line(LoadCtx *ctx) { SdbListIter *it; void *token_off_tmp; ctx->cur_db = ctx->root_db; - ls_foreach (ctx->path, it, token_off_tmp) { + ls_foreach_cast (ctx->path, it, void*, token_off_tmp) { size_t token_off = (size_t)token_off_tmp; if (!ctx->buf[token_off]) { continue; @@ -345,7 +351,7 @@ static bool load_process_final_line(LoadCtx *ctx) { // load_process_line needs ctx.buf[ctx.pos] to be allocated! // so we need room for one additional byte after the buffer. size_t linesz = ctx->bufsz - ctx->line_begin; - char *linebuf = malloc (linesz + 1); + char *linebuf = (char *)malloc (linesz + 1); if (!linebuf) { return false; } @@ -357,7 +363,7 @@ static bool load_process_final_line(LoadCtx *ctx) { ctx->token_begin -= ctx->line_begin; SdbListIter *it; void *token_off_tmp; - ls_foreach (ctx->path, it, token_off_tmp) { + ls_foreach_cast (ctx->path, it, void*, token_off_tmp) { it->data = (void *)((size_t)token_off_tmp - ctx->line_begin); } ctx->line_begin = 0; @@ -416,17 +422,18 @@ SDB_API bool sdb_text_load(Sdb *s, const char *file) { return false; } bool r = false; + char *x = NULL; struct stat st; if (fstat (fd, &st) || !st.st_size) { goto beach; } #if USE_MMAN - char *x = mmap (0, st.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); + x = (char *)mmap (0, st.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); if (x == MAP_FAILED) { goto beach; } #else - char *x = calloc (1, st.st_size); + x = (char *)calloc (1, st.st_size); if (!x) { goto beach; } diff --git a/shlr/sdb/src/types.h b/shlr/sdb/src/types.h index dbb70809cfe26..ecc574de997d0 100644 --- a/shlr/sdb/src/types.h +++ b/shlr/sdb/src/types.h @@ -12,7 +12,7 @@ #undef eprintf #define eprintf(...) fprintf(stderr,__VA_ARGS__) -// Copied from https://gcc.gnu.org/wiki/Visibility +// Inspired in https://gcc.gnu.org/wiki/Visibility #ifndef SDB_API #undef SDB_IPI #if defined _WIN32 || defined __CYGWIN__ diff --git a/shlr/sdb/src/util.c b/shlr/sdb/src/util.c index 27baef72b0701..dfeac0fcc4051 100644 --- a/shlr/sdb/src/util.c +++ b/shlr/sdb/src/util.c @@ -246,7 +246,9 @@ SDB_API int sdb_alen_ignore_empty(const char *str) { } len++; } - if (*p) len++; + if (*p) { + len++; + } return len; } From 333e99190a0c590de1c333aaeafb2aadac510fe9 Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 24 Feb 2022 01:11:08 +0100 Subject: [PATCH 058/390] Update list of file extensions considered scripts --- libr/core/libs.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libr/core/libs.c b/libr/core/libs.c index 9f3320687c976..8b1d2239e7396 100644 --- a/libr/core/libs.c +++ b/libr/core/libs.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2009-2021 - pancake */ +/* radare2 - LGPL - Copyright 2009-2022 - pancake */ #include "r_core.h" #include "config.h" @@ -117,13 +117,18 @@ static bool __isScriptFilename(const char *name) { const char *ext = r_str_lchr (name, '.'); if (ext) { ext++; - if (!strcmp (ext, "py") - || !strcmp (ext, "js") - || !strcmp (ext, "v") - || !strcmp (ext, "c") - || !strcmp (ext, "vala") - || !strcmp (ext, "pl") - || !strcmp (ext, "lua")) { + if (0 + || !strcmp (ext, "c") + || !strcmp (ext, "go") + || !strcmp (ext, "js") + || !strcmp (ext, "lua") + || !strcmp (ext, "pl") + || !strcmp (ext, "py") + || !strcmp (ext, "qjs") + || !strcmp (ext, "rs") + || !strcmp (ext, "v") + || !strcmp (ext, "vala") + || !strcmp (ext, "wren")) { return true; } } From 634b886e84a5c568d243e744becc6b3223e089cf Mon Sep 17 00:00:00 2001 From: pancake Date: Wed, 23 Feb 2022 22:54:54 +0100 Subject: [PATCH 059/390] Fix DoS in PE/QNX/DYLDCACHE/PSX parsers ##crash * Reported by lazymio * Reproducer: AAA4AAAAAB4= --- libr/bin/format/pe/pe.c | 18 ++++++++---------- libr/bin/p/bin_dyldcache.c | 2 +- libr/bin/p/bin_psxexe.c | 4 ++-- libr/bin/p/bin_qnx.c | 14 +++++++------- libr/util/buf.c | 6 ++---- 5 files changed, 20 insertions(+), 24 deletions(-) diff --git a/libr/bin/format/pe/pe.c b/libr/bin/format/pe/pe.c index e133451d08470..7718abebca8e0 100644 --- a/libr/bin/format/pe/pe.c +++ b/libr/bin/format/pe/pe.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2008-2021 nibble, pancake, inisider */ +/* radare - LGPL - Copyright 2008-2022 nibble, pancake, inisider */ #include #include @@ -278,15 +278,13 @@ struct r_bin_pe_addr_t *PE_(check_msvcseh)(RBinPEObj *pe) { } struct r_bin_pe_addr_t *PE_(check_mingw)(RBinPEObj *pe) { - struct r_bin_pe_addr_t* entry; bool sw = false; - ut8 b[1024]; + ut8 b[1024] = {0}; size_t n = 0; if (!pe || !pe->b) { return 0LL; } - entry = PE_(r_bin_pe_get_entrypoint) (pe); - ZERO_FILL (b); + struct r_bin_pe_addr_t* entry = PE_(r_bin_pe_get_entrypoint) (pe); if (r_buf_read_at (pe->b, entry->paddr, b, sizeof (b)) < 0) { pe_printf ("Warning: Cannot read entry at 0x%08"PFMT64x "\n", entry->paddr); free (entry); @@ -339,11 +337,11 @@ struct r_bin_pe_addr_t *PE_(check_unknow)(RBinPEObj *pe) { if (!pe || !pe->b) { return 0LL; } - ut8 b[512]; + ut8 b[512] = {0}; ZERO_FILL (b); entry = PE_ (r_bin_pe_get_entrypoint) (pe); // option2: /x 8bff558bec83ec20 - if (r_buf_read_at (pe->b, entry->paddr, b, 512) < 1) { + if (r_buf_read_at (pe->b, entry->paddr, b, sizeof (b)) != sizeof (b)) { pe_printf ("Warning: Cannot read entry at 0x%08"PFMT64x"\n", entry->paddr); free (entry); return NULL; @@ -537,7 +535,8 @@ static int bin_pe_parse_imports(RBinPEObj* pe, if (len < 1) { pe_printf ("Warning: read (import name)\n"); goto error; - } else if (!*name) { + } + if (!*name) { break; } name[PE_NAME_LENGTH] = '\0'; @@ -1258,7 +1257,6 @@ static bool bin_pe_init_metadata_hdr(RBinPEObj* pe) { // read the header after the string rr = r_buf_fread_at (pe->b, metadata_directory + 16 + metadata->VersionStringLength, (ut8*) (&metadata->Flags), pe->big_endian? "2S": "2s", 1); - if (rr < 1) { goto fail; } @@ -1820,7 +1818,7 @@ static Var* Pe_r_bin_pe_parse_var(RBinPEObj* pe, PE_DWord* curAddr) { free_Var (var); return NULL; } - if (r_buf_read_at (pe->b, *curAddr, (ut8*) var->szKey, TRANSLATION_UTF_16_LEN) < 1) { + if (r_buf_read_at (pe->b, *curAddr, (ut8*) var->szKey, TRANSLATION_UTF_16_LEN) != TRANSLATION_UTF_16_LEN) { pe_printf ("Warning: read (Var szKey)\n"); free_Var (var); return NULL; diff --git a/libr/bin/p/bin_dyldcache.c b/libr/bin/p/bin_dyldcache.c index 6b7b512b71365..d5700f1682151 100644 --- a/libr/bin/p/bin_dyldcache.c +++ b/libr/bin/p/bin_dyldcache.c @@ -587,7 +587,7 @@ static ut64 estimate_slide(RBinFile *bf, RDyldCache *cache, ut64 value_mask, ut6 int n_classes = classlist_sample_size / 8; ut64 sect_offset = sections[classlist_idx].offset + bin->hdr_offset; - if (r_buf_fread_at (cache->buf, sect_offset, (ut8*) classlist, "l", n_classes) < classlist_sample_size) { + if (r_buf_fread_at (cache->buf, sect_offset, (ut8*) classlist, "l", n_classes) != classlist_sample_size) { goto next_bin; } diff --git a/libr/bin/p/bin_psxexe.c b/libr/bin/p/bin_psxexe.c index 56e90384a863b..5865bf0677be9 100644 --- a/libr/bin/p/bin_psxexe.c +++ b/libr/bin/p/bin_psxexe.c @@ -57,7 +57,7 @@ static RList* sections(RBinFile* bf) { return NULL; } - if (r_buf_fread_at (bf->buf, 0, (ut8*)&psxheader, "8c17i", 1) < sizeof (psxexe_header)) { + if (r_buf_fread_at (bf->buf, 0, (ut8*)&psxheader, "8c17i", 1) != sizeof (psxexe_header)) { eprintf ("Truncated Header\n"); free (sect); r_list_free (ret); @@ -93,7 +93,7 @@ static RList* entries(RBinFile* bf) { return NULL; } - if (r_buf_fread_at (bf->buf, 0, (ut8*)&psxheader, "8c17i", 1) < sizeof (psxexe_header)) { + if (r_buf_fread_at (bf->buf, 0, (ut8*)&psxheader, "8c17i", 1) != sizeof (psxexe_header)) { eprintf ("PSXEXE Header truncated\n"); r_list_free (ret); free (addr); diff --git a/libr/bin/p/bin_qnx.c b/libr/bin/p/bin_qnx.c index c3e93c930a3c7..a00e2631faf43 100644 --- a/libr/bin/p/bin_qnx.c +++ b/libr/bin/p/bin_qnx.c @@ -7,7 +7,7 @@ static int lmf_header_load(lmf_header *lmfh, RBuffer *buf, Sdb *db) { if (r_buf_size (buf) < sizeof (lmf_header)) { return false; } - if (r_buf_fread_at (buf, QNX_HEADER_ADDR, (ut8 *) lmfh, "iiiiiiiicccciiiicc", 1) < QNX_HDR_SIZE) { + if (r_buf_fread_at (buf, QNX_HEADER_ADDR, (ut8 *) lmfh, "iiiiiiiicccciiiicc", 1) != QNX_HDR_SIZE) { return false; } r_strf_buffer (32); @@ -64,7 +64,7 @@ static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *buf, ut64 loadadd goto beach; } // Read the first record - if (r_buf_fread_at (bf->buf, 0, (ut8 *)&lrec, "ccss", 1) < QNX_RECORD_SIZE) { + if (r_buf_fread_at (bf->buf, 0, (ut8 *)&lrec, "ccss", 1) != QNX_RECORD_SIZE) { goto beach; } // Load the header @@ -72,7 +72,7 @@ static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *buf, ut64 loadadd offset += lrec.data_nbytes; for (;;) { - if (r_buf_fread_at (bf->buf, offset, (ut8 *)&lrec, "ccss", 1) < QNX_RECORD_SIZE) { + if (r_buf_fread_at (bf->buf, offset, (ut8 *)&lrec, "ccss", 1) != QNX_RECORD_SIZE) { goto beach; } offset += sizeof (lmf_record); @@ -84,7 +84,7 @@ static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *buf, ut64 loadadd if (!ptr) { goto beach; } - if (r_buf_fread_at (bf->buf, offset, (ut8 *)&lres, "ssss", 1) < sizeof (lmf_resource)) { + if (r_buf_fread_at (bf->buf, offset, (ut8 *)&lres, "ssss", 1) != sizeof (lmf_resource)) { goto beach; } ptr->name = strdup ("LMF_RESOURCE"); @@ -95,7 +95,7 @@ static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *buf, ut64 loadadd r_list_append (sections, ptr); } else if (lrec.rec_type == LMF_LOAD_REC) { RBinSection *ptr = R_NEW0 (RBinSection); - if (r_buf_fread_at (bf->buf, offset, (ut8 *)&ldata, "si", 1) < sizeof (lmf_data)) { + if (r_buf_fread_at (bf->buf, offset, (ut8 *)&ldata, "si", 1) != sizeof (lmf_data)) { goto beach; } if (!ptr) { @@ -110,7 +110,7 @@ static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *buf, ut64 loadadd r_list_append (sections, ptr); } else if (lrec.rec_type == LMF_FIXUP_REC) { RBinReloc *ptr = R_NEW0 (RBinReloc); - if (!ptr || r_buf_fread_at (bf->buf, offset, (ut8 *)&ldata, "si", 1) < sizeof (lmf_data)) { + if (!ptr || r_buf_fread_at (bf->buf, offset, (ut8 *)&ldata, "si", 1) != sizeof (lmf_data)) { goto beach; } ptr->vaddr = ptr->paddr = ldata.offset; @@ -118,7 +118,7 @@ static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *buf, ut64 loadadd r_list_append (fixups, ptr); } else if (lrec.rec_type == LMF_8087_FIXUP_REC) { RBinReloc *ptr = R_NEW0 (RBinReloc); - if (!ptr || r_buf_fread_at (bf->buf, offset, (ut8 *)&ldata, "si", 1) < sizeof (lmf_data)) { + if (!ptr || r_buf_fread_at (bf->buf, offset, (ut8 *)&ldata, "si", 1) != sizeof (lmf_data)) { goto beach; } ptr->vaddr = ptr->paddr = ldata.offset; diff --git a/libr/util/buf.c b/libr/util/buf.c index b20e481d4701e..5aa93ca64bc51 100644 --- a/libr/util/buf.c +++ b/libr/util/buf.c @@ -516,10 +516,9 @@ static st64 buf_format(RBuffer *dst, RBuffer *src, const char *fmt, int n) { ut32 d3; ut64 d4; st64 r = r_buf_read (src, tmp, tsize); - if (r < tsize) { + if (r != tsize) { return -1; } - switch (tsize) { case 1: d1 = r_read_ble8 (tmp); @@ -566,7 +565,7 @@ R_API st64 r_buf_fread_at(RBuffer *b, ut64 addr, ut8 *buf, const char *fmt, int return r; } r = r_buf_fread (b, buf, fmt, n); - r_buf_seek (b, o_addr, R_BUF_SET); + (void)r_buf_seek (b, o_addr, R_BUF_SET); return r; } @@ -598,7 +597,6 @@ R_API st64 r_buf_read_at(RBuffer *b, ut64 addr, ut8 *buf, ut64 len) { if (r < 0) { return r; } - r = r_buf_read (b, buf, len); r_buf_seek (b, o_addr, R_BUF_SET); return r; From 2178cd24a3023052b97838a70c5f598572b7a2ab Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 24 Feb 2022 11:30:33 +0100 Subject: [PATCH 060/390] Restore and revert blocksize in V: ##visual --- libr/core/visual.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libr/core/visual.c b/libr/core/visual.c index 12a3f0eca507b..01b6d07ac4874 100644 --- a/libr/core/visual.c +++ b/libr/core/visual.c @@ -775,11 +775,18 @@ R_API void r_core_visual_prompt_input(RCore *core) { r_cons_show_cursor (true); core->vmode = false; + int curbs = core->blocksize; + if (autoblocksize) { + r_core_block_size (core, obs); + } backup_current_addr (core, &addr, &bsze, &newaddr); do { ret = r_core_visual_prompt (core); } while (ret); restore_current_addr (core, addr, bsze, newaddr); + if (autoblocksize) { + r_core_block_size (core, curbs); + } r_cons_show_cursor (false); core->vmode = true; From 837d781879bf6217cf0265f1279fd97a5e7b37d3 Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 24 Feb 2022 11:47:37 +0100 Subject: [PATCH 061/390] Fix memory leak in RCore.cmdQueue --- libr/core/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libr/core/core.c b/libr/core/core.c index 723ded7e4e85d..f7a4373243c8d 100644 --- a/libr/core/core.c +++ b/libr/core/core.c @@ -1,4 +1,4 @@ -/* radare2 - LGPL - Copyright 2009-2021 - pancake */ +/* radare2 - LGPL - Copyright 2009-2022 - pancake */ #include #include @@ -3319,6 +3319,7 @@ R_API void r_core_cmd_queue_wait(RCore *core) { if (cmd) { r_core_cmd0 (core, cmd); r_cons_flush (); + free (cmd); } r_sys_usleep (100); } @@ -3367,6 +3368,7 @@ R_API int r_core_prompt_exec(RCore *r) { break; } ret = r_core_cmd (r, cmd, true); + free (cmd); if (ret < 0) { if (r->cons && r->cons->line && r->cons->line->zerosep) { r_cons_zero (); @@ -3376,7 +3378,6 @@ R_API int r_core_prompt_exec(RCore *r) { } r->rc = r->num->value; // int ret = r_core_cmd (r, cmd, true); - free (cmd); if (r->cons && r->cons->context->use_tts) { const char *buf = r_cons_get_buffer (); if (buf && *buf) { From 79d108a4c2eac28ec36ce3aa7abd11142b1ee3a3 Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 24 Feb 2022 11:53:10 +0100 Subject: [PATCH 062/390] Fix off by one read in psw --- libr/core/cmd_print.c | 2 +- libr/core/cmd_write.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index 0a6e6a2fbfb26..1e74451e1c46e 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -4710,7 +4710,7 @@ static void print_json_string(RCore *core, const char* block, int len, const cha tblock = r_mem_dup (block, len); for (i = 0; i < len; i++) { if (tblock[i] && !tblock[i + 1]) { - memmove (tblock + i + 1, tblock + i + 2, len - i - 1); + memmove (tblock + i + 1, tblock + i + 2, len - i - 2); } else { tblock[i] = 0; break; diff --git a/libr/core/cmd_write.c b/libr/core/cmd_write.c index 1b83aeddbade5..40b93028309c1 100644 --- a/libr/core/cmd_write.c +++ b/libr/core/cmd_write.c @@ -1437,11 +1437,9 @@ static int wz_handler_old(void *data, const char *input) { } else { core->num->value = 0; } -#if 0 - r_io_use_desc (core->io, core->file->desc); -#endif WSEEK (core, len + 1); r_core_block_read (core); + free (str); return 0; } From 83f55161d1936898d1b429603fda057bddbbafda Mon Sep 17 00:00:00 2001 From: pancake Date: Fri, 25 Feb 2022 00:45:07 +0100 Subject: [PATCH 063/390] Fix negative allocation in mdmpdos --- libr/core/cbin.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libr/core/cbin.c b/libr/core/cbin.c index 6b2322c80f08f..9565ce954c6e5 100644 --- a/libr/core/cbin.c +++ b/libr/core/cbin.c @@ -243,6 +243,9 @@ R_API void r_core_bin_export_info(RCore *core, int mode) { int fmtsize = r_print_format_struct_size (core->print, v, 0, 0); char *offset_key = r_str_newf ("%s.offset", flagname); const char *off = sdb_const_get (db, offset_key, 0); + if (fmtsize < 1) { + continue; + } free (offset_key); if (off) { if (IS_MODE_RAD (mode)) { From 258656a1c9d8edf6d7dd70f9f667a96b74636ff3 Mon Sep 17 00:00:00 2001 From: pancake Date: Fri, 25 Feb 2022 13:30:43 +0100 Subject: [PATCH 064/390] Update to the latest sdb and acr --- configure | 4 ++-- configure.acr | 13 +++++++------ shlr/sdb/src/cdb_make.c | 2 +- shlr/sdb/src/types.h | 15 ++++++++------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/configure b/configure index c22b54eb1a2c2..56f2280d7b461 100755 --- a/configure +++ b/configure @@ -885,9 +885,9 @@ do_remove if [ "$QUIET" = 0 ]; then echo echo "Final report:" -for A in R_CHECKS_LEVEL PREFIX HAVE_LIB_GMP HAVE_OPENSSL HAVE_LIBUV USE_CAPSTONE HAVE_PTRACE USE_PTRACE_WRAP HAVE_FORK USE_LIB_LZ4 VERSION USE_LIB_ZIP USE_LIB_MAGIC USE_LIB_XXHASH DEBUGGER CC USERCC HAVE_ARC4RANDOM_UNIFORM PKGCONFIG HAVE_GPERF HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET WANT_DYLINK USEROSTYPE LIBVERSION BUILD HOST TARGET CFLAGS LDFLAGS ; do +for A in BUILD CC CFLAGS DEBUGGER HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET HAVE_FORK HAVE_GPERF HAVE_LIBUV HAVE_LIB_GMP HAVE_OPENSSL HAVE_PTRACE HOST LDFLAGS LIBVERSION PKGCONFIG PREFIX R_CHECKS_LEVEL TARGET USERCC USEROSTYPE USE_CAPSTONE USE_LIB_MAGIC USE_LIB_XXHASH USE_LIB_ZIP USE_PTRACE_WRAP USE_SYSLZ4 VERSION WANT_DYLINK ; do eval VAL="\$${A}" -[ -z "${VAL}" ] && VAL="(null)" +[ -z "${VAL}" ] && VAL="\"\"" echo " - ${A} = ${VAL}" done fi diff --git a/configure.acr b/configure.acr index 597db81bf0b87..54d66d5888352 100644 --- a/configure.acr +++ b/configure.acr @@ -261,12 +261,13 @@ IFEQ WANT_PTRACE_WRAP 0 ; { ARG_WITH R_CHECKS_LEVEL=2 checks-level value between 0 and 3 to enable different level of assert (see R_CHECKS_LEVEL) ; -REPORT R_CHECKS_LEVEL PREFIX HAVE_LIB_GMP HAVE_OPENSSL HAVE_LIBUV - USE_CAPSTONE HAVE_PTRACE USE_PTRACE_WRAP HAVE_FORK - USE_LIB_LZ4 VERSION USE_LIB_ZIP USE_LIB_MAGIC USE_LIB_XXHASH DEBUGGER - CC USERCC HAVE_ARC4RANDOM_UNIFORM PKGCONFIG HAVE_GPERF - HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET WANT_DYLINK USEROSTYPE - LIBVERSION BUILD HOST TARGET CFLAGS LDFLAGS ; +REPORT + BUILD CC CFLAGS DEBUGGER HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO + HAVE_EXPLICIT_MEMSET HAVE_FORK HAVE_GPERF HAVE_LIBUV HAVE_LIB_GMP + HAVE_OPENSSL HAVE_PTRACE HOST LDFLAGS LIBVERSION PKGCONFIG PREFIX + R_CHECKS_LEVEL TARGET USERCC USEROSTYPE USE_CAPSTONE USE_LIB_MAGIC + USE_LIB_XXHASH USE_LIB_ZIP USE_PTRACE_WRAP USE_SYSLZ4 VERSION WANT_DYLINK +; (( TODO: Add the rest of .pc files here.. add a rule for acr? )) SUBDIRS ./config-user.mk diff --git a/shlr/sdb/src/cdb_make.c b/shlr/sdb/src/cdb_make.c index 96b2f8d36b8cb..1e99c1c976c49 100644 --- a/shlr/sdb/src/cdb_make.c +++ b/shlr/sdb/src/cdb_make.c @@ -9,7 +9,7 @@ char *cdb_alloc(ut32 n) { #if __APPLE__ && !__POWERPC__ void *ret = NULL; - return (char *)posix_memalign (&ret, ALIGNMENT, n)? NULL: ret; + return (char *)(posix_memalign (&ret, ALIGNMENT, n)? NULL: ret); #elif __SDB_WINDOWS__ && !__CYGWIN__ return (char *)_aligned_malloc (n, ALIGNMENT); #else diff --git a/shlr/sdb/src/types.h b/shlr/sdb/src/types.h index ecc574de997d0..1be29e3241a24 100644 --- a/shlr/sdb/src/types.h +++ b/shlr/sdb/src/types.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -46,7 +47,7 @@ #include #include #if __MINGW32__ -#define ULLFMT "ll" +#define ULLFMT PRIx64 #else #define ULLFMT "I64" #endif @@ -60,7 +61,7 @@ #include #undef HAVE_MMAN #define HAVE_MMAN 1 -#define ULLFMT "ll" +#define ULLFMT PRIx64 #endif #if __wasi__ || EMSCRIPTEN @@ -83,11 +84,11 @@ #endif #ifndef ut8 -#define ut8 unsigned char -#define ut32 unsigned int -#define ut64 unsigned long long -#define st64 long long -#define boolt int +#define ut8 uint8_t +#define ut32 uint32_t +#define ut64 uint64_t +#define st64 int64_t + // TODO: deprecate R_NEW #ifndef R_NEW //it means we are within sdb From 8959e053bc71fb89a3a5eec50bd3d0de2f5fdc1b Mon Sep 17 00:00:00 2001 From: pancake Date: Fri, 25 Feb 2022 16:17:37 +0100 Subject: [PATCH 065/390] Add some sign extend to some v850 st/sst insns ##esil --- libr/anal/arch/v850np/opc.inc | 30 ++++++++++++++++-------------- libr/anal/esil.c | 3 +-- shlr/sdb/src/types.h | 15 +++++++-------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/libr/anal/arch/v850np/opc.inc b/libr/anal/arch/v850np/opc.inc index fe12f6262a4ad..851fa479be8a2 100644 --- a/libr/anal/arch/v850np/opc.inc +++ b/libr/anal/arch/v850np/opc.inc @@ -1009,27 +1009,29 @@ const struct v850_opcode v850_opcodes[] = { { "shr", two (0x07e0, 0x0082), two (0x07e0, 0x07ff), {R1, R2, R3}, 0, V850_CPU_E2_UP, R_ANAL_OP_TYPE_SHR, "#0,#1,>>,#1,=" }, { "shr", OP (0x14), OP_MASK, {I5U, R2}, 0, V850_CPU_ALL, R_ANAL_OP_TYPE_SHR, "#0,#1,>>,#1,=" }, { "shr", two (0x07e0, 0x0080), two (0x07e0, 0xffff), {R1, R2}, 0, V850_CPU_ALL, R_ANAL_OP_TYPE_SHR, "#0,#1,>>,#1,=" }, - { "sld.b", one (0x0300), one (0x0780), {D7U, EP, R2}, 2, V850_CPU_ALL }, - { "sld.bu", one (0x0060), one (0x07f0), {D4U, EP, R2_NOTR0}, 2, V850_CPU_NON0 }, - { "sld.h", one (0x0400), one (0x0780), {D8_7U,EP, R2}, 2, V850_CPU_ALL }, - { "sld.hu", one (0x0070), one (0x07f0), {D5_4U,EP, R2_NOTR0}, 2, V850_CPU_NON0 }, - { "sld.w", one (0x0500), one (0x0781), {D8_6U,EP, R2}, 2, V850_CPU_ALL }, + + { "sld.b", one (0x0300), one (0x0780), {D7U, EP, R2}, 2, V850_CPU_ALL, R_ANAL_OP_TYPE_LOAD, "1,#0,>>,#1,ep,+,[1],4,#1,=" }, + { "sld.bu", one (0x0060), one (0x07f0), {D4U, EP, R2_NOTR0}, 2, V850_CPU_NON0, R_ANAL_OP_TYPE_LOAD }, + { "sld.h", one (0x0400), one (0x0780), {D8_7U,EP, R2}, 2, V850_CPU_ALL, R_ANAL_OP_TYPE_LOAD }, + { "sld.hu", one (0x0070), one (0x07f0), {D5_4U,EP, R2_NOTR0}, 2, V850_CPU_NON0, R_ANAL_OP_TYPE_LOAD }, + { "sld.w", one (0x0500), one (0x0781), {D8_6U,EP, R2}, 2, V850_CPU_ALL, R_ANAL_OP_TYPE_LOAD }, + { "snooze", two (0x0fe0, 0x0120), two (0xffff, 0xffff), {0}, 0, V850_CPU_E3V5_UP }, - { "sst.b", one (0x0380), one (0x0780), {R2, D7U, EP}, 3, V850_CPU_ALL }, - { "sst.h", one (0x0480), one (0x0780), {R2, D8_7U,EP}, 3, V850_CPU_ALL }, - { "sst.w", one (0x0501), one (0x0781), {R2, D8_6U,EP}, 3, V850_CPU_ALL }, + { "sst.b", one (0x0380), one (0x0780), {R2, D7U, EP}, 3, V850_CPU_ALL, R_ANAL_OP_TYPE_STORE, "#0,[1],ep,~,=[1]"}, + { "sst.h", one (0x0480), one (0x0780), {R2, D8_7U,EP}, 3, V850_CPU_ALL, R_ANAL_OP_TYPE_STORE }, + { "sst.w", one (0x0501), one (0x0781), {R2, D8_6U,EP}, 3, V850_CPU_ALL, R_ANAL_OP_TYPE_STORE }, { "stacch", two (0x07e0, 0x0bca), two (0x07ff, 0xffff), {R2}, 0, V850_CPU_E2_UP | V850_CPU_OPTION_EXTENSION }, { "staccl", two (0x07e0, 0x0bc8), two (0x07ff, 0xffff), {R2}, 0, V850_CPU_E2_UP | V850_CPU_OPTION_EXTENSION }, - { "st.b", two (0x0740, 0x0000), two (0x07e0, 0x0000), {R2, D16, R1}, 3, V850_CPU_ALL, R_ANAL_OP_TYPE_STORE, "#0,#1,#2,+,=[4]" }, - { "st.b", two (0x0780, 0x000d), two (0x07e0, 0x000f), {R3, D23, R1}, 3, V850_CPU_E2_UP, R_ANAL_OP_TYPE_STORE }, + { "st.b", two (0x0740, 0x0000), two (0x07e0, 0x0000), {R2, D16, R1}, 3, V850_CPU_ALL, R_ANAL_OP_TYPE_STORE, "#0,#1,#2,+,~,=[4]" }, + { "st.b", two (0x0780, 0x000d), two (0x07e0, 0x000f), {R3, D23, R1}, 3, V850_CPU_E2_UP, R_ANAL_OP_TYPE_STORE, "#0,#1,#2,+,~,=[4]" }, { "st.b23", two (0x0780, 0x000d), two (0x07e0, 0x000f), {R3, D23, R1}, 3, V850_CPU_E2_UP | V850_CPU_OPTION_ALIAS, R_ANAL_OP_TYPE_STORE }, { "st.dw", two (0x07a0, 0x000f), two (0xffe0, 0x001f), {R3_EVEN, D23_ALIGN1, R1}, 3, V850_CPU_E3V5_UP, R_ANAL_OP_TYPE_STORE }, { "st.dw23", two (0x07a0, 0x000f), two (0xffe0, 0x001f), {R3_EVEN, D23_ALIGN1, R1}, 3, V850_CPU_E3V5_UP | V850_CPU_OPTION_ALIAS, R_ANAL_OP_TYPE_STORE }, - { "st.h", two (0x0760, 0x0000), two (0x07e0, 0x0001), {R2, D16_15, R1}, 3, V850_CPU_ALL, R_ANAL_OP_TYPE_STORE }, - { "st.h", two (0x07a0, 0x000d), two (0x07e0, 0x000f), {R3, D23_ALIGN1, R1}, 3, V850_CPU_E2_UP, R_ANAL_OP_TYPE_STORE }, + { "st.h", two (0x0760, 0x0000), two (0x07e0, 0x0001), {R2, D16_15, R1}, 3, V850_CPU_ALL, R_ANAL_OP_TYPE_STORE, "#0,#1,~,=[4]" }, + { "st.h", two (0x07a0, 0x000d), two (0x07e0, 0x000f), {R3, D23_ALIGN1, R1}, 3, V850_CPU_E2_UP, R_ANAL_OP_TYPE_STORE, "#0,#1,~,=[4]" }, { "st.h23", two (0x07a0, 0x000d), two (0x07e0, 0x000f), {R3, D23_ALIGN1, R1}, 3, V850_CPU_E2_UP | V850_CPU_OPTION_ALIAS, R_ANAL_OP_TYPE_STORE }, - { "st.w", two (0x0760, 0x0001), two (0x07e0, 0x0001), {R2, D16_15, R1}, 3, V850_CPU_ALL, R_ANAL_OP_TYPE_STORE, "#0,#1,=[4]" }, - { "st.w", two (0x0780, 0x000f), two (0x07e0, 0x000f), {R3, D23_ALIGN1, R1}, 3, V850_CPU_E2_UP, R_ANAL_OP_TYPE_STORE, "#0,#1,=[4]" }, + { "st.w", two (0x0760, 0x0001), two (0x07e0, 0x0001), {R2, D16_15, R1}, 3, V850_CPU_ALL, R_ANAL_OP_TYPE_STORE, "#0,#1,~,=[4]" }, + { "st.w", two (0x0780, 0x000f), two (0x07e0, 0x000f), {R3, D23_ALIGN1, R1}, 3, V850_CPU_E2_UP, R_ANAL_OP_TYPE_STORE, "#0,#1,~,=[4]" }, { "st.w23", two (0x0780, 0x000f), two (0x07e0, 0x000f), {R3, D23_ALIGN1, R1}, 3, V850_CPU_E2_UP | V850_CPU_OPTION_ALIAS, R_ANAL_OP_TYPE_STORE }, { "stc.w", two (0x07e0, 0x037a), two (0xffe0, 0x07ff), {R3, R1}, 2, V850_CPU_E3V5_UP, R_ANAL_OP_TYPE_STORE }, { "stsr", two (0x07e0, 0x0040), two (0x07e0, 0x07ff), {SR1, R2, SELID}, 0, V850_CPU_E3V5_UP, R_ANAL_OP_TYPE_STORE }, diff --git a/libr/anal/esil.c b/libr/anal/esil.c index 309de42f463db..0d11b5f58c25a 100644 --- a/libr/anal/esil.c +++ b/libr/anal/esil.c @@ -607,9 +607,8 @@ R_API bool r_anal_esil_signext(RAnalEsil *esil, bool assign) { free (p_src); free (p_dst); return false; - } else { - free (p_dst); } + free (p_dst); //Make sure the other bits are 0 src &= UT64_MAX >> (64 - dst); diff --git a/shlr/sdb/src/types.h b/shlr/sdb/src/types.h index 1be29e3241a24..ecc574de997d0 100644 --- a/shlr/sdb/src/types.h +++ b/shlr/sdb/src/types.h @@ -6,7 +6,6 @@ #include #include #include -#include #include #include @@ -47,7 +46,7 @@ #include #include #if __MINGW32__ -#define ULLFMT PRIx64 +#define ULLFMT "ll" #else #define ULLFMT "I64" #endif @@ -61,7 +60,7 @@ #include #undef HAVE_MMAN #define HAVE_MMAN 1 -#define ULLFMT PRIx64 +#define ULLFMT "ll" #endif #if __wasi__ || EMSCRIPTEN @@ -84,11 +83,11 @@ #endif #ifndef ut8 -#define ut8 uint8_t -#define ut32 uint32_t -#define ut64 uint64_t -#define st64 int64_t - +#define ut8 unsigned char +#define ut32 unsigned int +#define ut64 unsigned long long +#define st64 long long +#define boolt int // TODO: deprecate R_NEW #ifndef R_NEW //it means we are within sdb From a9829f757fc9bacaea340c19e8a0862c042dedcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20=C3=80lvarez=20i=20Capilla?= Date: Fri, 25 Feb 2022 16:49:30 +0100 Subject: [PATCH 066/390] Let users change the blocksize from visual prompt --- libr/core/visual.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libr/core/visual.c b/libr/core/visual.c index 01b6d07ac4874..77c7cc6b97383 100644 --- a/libr/core/visual.c +++ b/libr/core/visual.c @@ -1,7 +1,6 @@ /* radare - LGPL - Copyright 2009-2022 - pancake */ #include -#include #define NPF 5 #define PIDX (R_ABS (core->printidx % NPF)) @@ -785,6 +784,7 @@ R_API void r_core_visual_prompt_input(RCore *core) { } while (ret); restore_current_addr (core, addr, bsze, newaddr); if (autoblocksize) { + obs = core->blocksize; r_core_block_size (core, curbs); } From 0ad181b464ec24d56195d3f8cbb2dca066e4d62f Mon Sep 17 00:00:00 2001 From: pancake Date: Fri, 25 Feb 2022 22:28:23 +0100 Subject: [PATCH 067/390] Sync sdb again from git --- shlr/sdb/src/cdb.c | 4 +- shlr/sdb/src/dict.c | 80 +++++++++++++++++++++------------------- shlr/sdb/src/dict.h | 12 +----- shlr/sdb/src/disk.c | 12 +++--- shlr/sdb/src/json.c | 4 +- shlr/sdb/src/json/path.c | 5 +-- shlr/sdb/src/ls.c | 2 +- shlr/sdb/src/main.c | 13 +++++-- shlr/sdb/src/query.c | 49 ++++++++++++------------ shlr/sdb/src/sdb.c | 2 +- shlr/sdb/src/sdb.h | 2 +- shlr/sdb/src/types.h | 15 ++++---- shlr/sdb/src/util.c | 2 +- 13 files changed, 101 insertions(+), 101 deletions(-) diff --git a/shlr/sdb/src/cdb.c b/shlr/sdb/src/cdb.c index ed460872a44b4..f7ee0d6cc50d8 100644 --- a/shlr/sdb/src/cdb.c +++ b/shlr/sdb/src/cdb.c @@ -54,7 +54,7 @@ bool cdb_init(struct cdb *c, int fd) { #if USE_MMAN char *x = (char *)mmap (0, st.st_size, PROT_READ, MAP_SHARED, fd, 0); if (x == MAP_FAILED) { - eprintf ("Cannot mmap %d\n", (int)st.st_size); + // eprintf ("Cannot mmap %d\n", (int)st.st_size); return false; } if (c->map) { @@ -63,7 +63,7 @@ bool cdb_init(struct cdb *c, int fd) { #else char *x = calloc (1, st.st_size); if (!x) { - eprintf ("Cannot malloc %d\n", (int)st.st_size); + // eprintf ("Cannot malloc %d\n", (int)st.st_size); return false; } /* TODO: read by chunks instead of a big huge syscall */ diff --git a/shlr/sdb/src/dict.c b/shlr/sdb/src/dict.c index d0bbdd595101e..4c04b07ac9774 100644 --- a/shlr/sdb/src/dict.c +++ b/shlr/sdb/src/dict.c @@ -2,7 +2,7 @@ #include "sdb.h" -SDB_API dict *dict_new (ut32 size, dict_freecb f) { +SDB_API dict *dict_new(ut32 size, dict_freecb f) { dict *m = (dict *)calloc (1, sizeof (dict)); if (!dict_init (m, R_MAX (size, 1), f)) { free (m); @@ -19,7 +19,7 @@ static ut32 dict_bucket(dict *m, dicti k) { return 0; } -SDB_API bool dict_init (dict *m, ut32 size, dict_freecb f) { +SDB_API bool dict_init(dict *m, ut32 size, dict_freecb f) { if (m) { memset (m, 0, sizeof (dict)); if (size > 0) { @@ -34,14 +34,14 @@ SDB_API bool dict_init (dict *m, ut32 size, dict_freecb f) { return true; } -SDB_API void dict_fini (dict *m) { - ut32 i; +SDB_API void dict_fini(dict *m) { if (m) { + ut32 i; if (m->f) { for (i = 0; i < m->size; i++) { dictkv *kv = (dictkv *)m->table[i]; if (kv) { - while (kv->k != MHTNO) { + while (kv->k != 0) { m->f (kv->u); kv++; } @@ -58,18 +58,20 @@ SDB_API void dict_fini (dict *m) { } } -SDB_API void dict_free (dict *m) { - dict_fini (m); - free (m); +SDB_API void dict_free(dict *m) { + if (m) { + dict_fini (m); + free (m); + } } // collisions are not handled in a dict. use a hashtable if you want to use strings as keys. -SDB_API dicti dict_hash (const char *s) { +SDB_API dicti dict_hash(const char *s) { return (dicti)sdb_hash (s); } -SDB_API bool dict_set (dict *m, dicti k, dicti v, void *u) { - if (!m || !m->size || k == MHTNO) { +SDB_API bool dict_set(dict *m, dicti k, dicti v, void *u) { + if (!m || !m->size || k == 0) { return false; } const int bucket = dict_bucket (m, k); @@ -78,15 +80,15 @@ SDB_API bool dict_set (dict *m, dicti k, dicti v, void *u) { kv = (dictkv *)calloc (sizeof (dictkv), 2); if (kv) { m->table[bucket] = kv; - kv->k = MHTNO; - kv->v = MHTNO; + kv->k = 0; + kv->v = 0; kv->u = NULL; return dict_set (m, k, v, u); } return false; } dictkv *tmp = kv; - while (kv->k != MHTNO) { + while (kv->k != 0) { if (kv->k == k) { kv->v = v; kv->u = u; @@ -104,38 +106,40 @@ SDB_API bool dict_set (dict *m, dicti k, dicti v, void *u) { kv->v = v; kv->u = u; kv++; - kv->k = MHTNO; - kv->v = MHTNO; + kv->k = 0; + kv->v = 0; kv->u = NULL; return true; } return false; } -SDB_API void dict_stats (dict *m) { - ut32 i, j; - for (i = 0; i < m->size; i++) { - printf ("%d: ", i); - j = 0; - dictkv *kv = (dictkv *)m->table[i]; +SDB_API ut32 dict_stats(dict *m, ut32 nb) { + if (((int)nb) < 0) { + return m->size - 1; + } + if (nb < m->size) { + ut32 j = 0; + dictkv *kv = (dictkv *)m->table[nb]; if (kv) { - while (kv->k != MHTNO) { + while (kv->k != 0) { j++; kv++; } } - printf ("%d\n", j); + return j; } + return 0; } -SDB_API dictkv *dict_getr (dict *m, dicti k) { +SDB_API dictkv *dict_getr(dict *m, dicti k) { if (!m->size) { return NULL; } int bucket = dict_bucket (m, k); dictkv *kv = (dictkv *)m->table[bucket]; if (kv) { - while (kv->k != MHTNO) { + while (kv->k != 0) { if (kv->k == k) { return kv; } @@ -145,39 +149,39 @@ SDB_API dictkv *dict_getr (dict *m, dicti k) { return NULL; } -SDB_API dicti dict_get (dict *m, dicti k) { +SDB_API dicti dict_get(dict *m, dicti k) { dictkv *kv = dict_getr (m, k); - return kv ? kv->v : MHTNO; + return kv ? kv->v : 0; } -SDB_API void *dict_getu (dict *m, dicti k) { +SDB_API void *dict_getu(dict *m, dicti k) { dictkv *kv = dict_getr (m, k); return kv ? kv->u : NULL; } -SDB_API bool dict_add (dict *m, dicti k, dicti v, void *u) { +SDB_API bool dict_add(dict *m, dicti k, dicti v, void *u) { return dict_getr (m, k) ? dict_set (m, k, v, u) : false; } -SDB_API bool dict_del (dict *m, dicti k) { +SDB_API bool dict_del(dict *m, dicti k) { int bucket = dict_bucket (m, k); - if (k == MHTNO) { + if (k == 0) { return false; } dictkv *kv = (dictkv *)m->table[bucket]; if (kv) { - while (kv->k != MHTNO) { + while (kv->k != 0) { if (kv->k == k) { if (m->f) { m->f (kv->u); } dictkv *n = (dictkv *)(kv + 1); - while (n->k != MHTNO) { + while (n->k != 0) { *kv++ = *n++; } - kv->k = MHTNO; + kv->k = 0; return true; } kv++; @@ -191,16 +195,16 @@ SDB_API bool dict_del (dict *m, dicti k) { // cb : function that accept a dictkv. When it returns a value != 0, the // iteration stops // u : additional information to pass to cb together with the dictkv -SDB_API void dict_foreach (dict *m, dictkv_cb cb, void *u) { +SDB_API void dict_foreach(dict *m, dictkv_cb cb, void *u) { bool iterate = true; ut32 i; for (i = 0; i < m->size && iterate; i++) { dictkv *kv = (dictkv *)m->table[i]; if (kv) { - while (kv->k != MHTNO) { + while (kv->k) { int res = cb (kv, u); - if (res != 0) { + if (res) { iterate = false; break; } diff --git a/shlr/sdb/src/dict.h b/shlr/sdb/src/dict.h index 7dfd2aeec9dec..e924316644f5b 100644 --- a/shlr/sdb/src/dict.h +++ b/shlr/sdb/src/dict.h @@ -1,6 +1,5 @@ #define MHTSZ 32 -#define MHTNO 0 typedef ut64 dicti; @@ -8,13 +7,6 @@ typedef struct { dicti k; dicti v; void *u; -#if 0 - // unaligned - // on 32bits - void *pad; - // on 64bits - void *pad; -#endif } dictkv; // 4 + 4 + 4 = 12 .. missing 4 more @@ -26,7 +18,7 @@ typedef void (*dict_freecb)(void *); typedef int (*dictkv_cb)(dictkv *, void *); typedef struct { - void **table; //[MHTSZ]; + void **table; dict_freecb f; ut32 size; } dict; @@ -37,7 +29,7 @@ SDB_API dict *dict_new(ut32 size, dict_freecb f); SDB_API void dict_free(dict*); SDB_API bool dict_init(dict *m, ut32, dict_freecb f); SDB_API void dict_fini(dict *m); -SDB_API void dict_stats(dict *m); +SDB_API ut32 dict_stats(dict *m, ut32 nb); SDB_API dicti dict_hash(const char *s); SDB_API bool dict_set(dict *m, dicti k, dicti v, void *u); SDB_API dictkv *dict_getr(dict *m, dicti k); diff --git a/shlr/sdb/src/disk.c b/shlr/sdb/src/disk.c index 897611c22cf67..a59113ce3a11a 100644 --- a/shlr/sdb/src/disk.c +++ b/shlr/sdb/src/disk.c @@ -33,7 +33,6 @@ static wchar_t *r_utf8_to_utf16_l (const char *cstring, int len) { static bool r_sys_mkdir(const char *path) { LPTSTR path_ = r_sys_conv_utf8_to_utf16 (path); bool ret = CreateDirectory (path_, NULL); - free (path_); return ret; } @@ -50,8 +49,7 @@ static bool r_sys_mkdir(const char *path) { #define r_sys_mkdir_failed() (errno != EEXIST) #endif -static inline int r_sys_mkdirp(char *dir) { - int ret = 1; +static inline bool mkdirp(char *dir) { const char slash = DIRSEP; char *path = dir; char *ptr = path; @@ -67,14 +65,14 @@ static inline int r_sys_mkdirp(char *dir) { while ((ptr = strchr (ptr, slash))) { *ptr = 0; if (!r_sys_mkdir (path) && r_sys_mkdir_failed ()) { - // eprintf ("r_sys_mkdirp: fail '%s' of '%s'\n", path, dir); + // eprintf ("cannot make directory r_sys_mkdirp: fail '%s' of '%s'\n", path, dir); *ptr = slash; - return 0; + return false; } *ptr = slash; ptr++; } - return ret; + return true; } SDB_API bool sdb_disk_create(Sdb* s) { @@ -95,7 +93,7 @@ SDB_API bool sdb_disk_create(Sdb* s) { return false; } memcpy (str, dir, nlen + 1); - r_sys_mkdirp (str); + mkdirp (str); memcpy (str + nlen, ".tmp", 5); if (s->fdump != -1) { close (s->fdump); diff --git a/shlr/sdb/src/json.c b/shlr/sdb/src/json.c index f351918f403a0..1f86954715beb 100644 --- a/shlr/sdb/src/json.c +++ b/shlr/sdb/src/json.c @@ -1,4 +1,4 @@ -/* sdb - MIT - Copyright 2012-2021 - pancake */ +/* sdb - MIT - Copyright 2012-2022 - pancake */ #include #include "sdb.h" @@ -307,7 +307,7 @@ SDB_API const char *sdb_json_format(SdbJsonString *s, const char *fmt, ...) { case 'l': JSONSTR_ALLOCATE (32); arg_l = va_arg (ap, ut64); - snprintf (tmp, sizeof (tmp), "0x%" ULLFMT "x", arg_l); + snprintf (tmp, sizeof (tmp), "0x%" PRIx64, arg_l); memcpy (s->buf + s->len, tmp, strlen (tmp)); s->len += strlen (tmp); break; diff --git a/shlr/sdb/src/json/path.c b/shlr/sdb/src/json/path.c index 87e24cfb4451a..e6aafc32736ee 100644 --- a/shlr/sdb/src/json/path.c +++ b/shlr/sdb/src/json/path.c @@ -1,4 +1,4 @@ -/* sdb - MIT - Copyright 2012-2021 - pancake */ +/* sdb - MIT - Copyright 2012-2022 - pancake */ #include #include @@ -125,8 +125,7 @@ SDB_IPI Rangstr json_find (const char *s, Rangstr *rs) { if (len > RESFIXSZ) { res = (RangstrType *)calloc (len + 1, sizeof (RangstrType)); if (!res) { - eprintf ("Cannot allocate %d byte%s\n", - len + 1, (len > 1)? "s": ""); + // eprintf ("Cannot allocate %d byte%s\n", len + 1, (len > 1)? "s": ""); return rangstr_null (); } } diff --git a/shlr/sdb/src/ls.c b/shlr/sdb/src/ls.c index b7cce872b66f3..4c99c8e0bdb5f 100644 --- a/shlr/sdb/src/ls.c +++ b/shlr/sdb/src/ls.c @@ -1,4 +1,4 @@ -/* sdb - MIT - Copyright 2007-2021 - pancake, alvaro */ +/* sdb - MIT - Copyright 2007-2022 - pancake, alvaro */ #include #include "ls.h" diff --git a/shlr/sdb/src/main.c b/shlr/sdb/src/main.c index b3b573482fd0d..4df5256864e38 100644 --- a/shlr/sdb/src/main.c +++ b/shlr/sdb/src/main.c @@ -291,7 +291,7 @@ static void sdb_dump_cb(MainOptions *mo, const char *k, const char *v, const cha if (!strcmp (v, "true") || !strcmp (v, "false")) { printf ("%s\"%s\":%s", comma, k, v); } else if (sdb_isnum (v)) { - printf ("%s\"%s\":%" ULLFMT "u", comma, k, sdb_atoi (v)); + printf ("%s\"%s\":%" PRIu64, comma, k, sdb_atoi (v)); } else if (*v == '{' || *v == '[') { printf ("%s\"%s\":%s", comma, k, v); } else { @@ -758,7 +758,10 @@ static int gen_gperf(MainOptions *mo, const char *file, const char *name) { if (wd == -1) { wd = open (out, O_RDWR | O_CREAT, 0644); } else { - ftruncate (wd, 0); + if (ftruncate (wd, 0) == -1) { + close (wd); + return -1; + } } int rc = -1; if (wd != -1) { @@ -781,6 +784,9 @@ static int gen_gperf(MainOptions *mo, const char *file, const char *name) { } else { if (rc == 0) { char *cname = get_cname (name); + if (!cname) { + return -1; + } snprintf (buf, buf_size, "gperf -aclEDCIG --null-strings -H sdb_hash_c_%s" " -N sdb_get_c_%s -t %s.gperf > %s.c\n", cname, cname, name, name); free (cname); @@ -792,8 +798,7 @@ static int gen_gperf(MainOptions *mo, const char *file, const char *name) { eprintf ("Generated %s.c and %s.h\n", name, name); } } else { - eprintf ("Cannot run gperf\n"); - eprintf ("%s\n", buf); + eprintf ("Cannot run gperf: %s\n", buf); } } else { eprintf ("Outdated sdb binary in PATH?\n"); diff --git a/shlr/sdb/src/query.c b/shlr/sdb/src/query.c index 05170c201e077..7906ddc0b7f2f 100644 --- a/shlr/sdb/src/query.c +++ b/shlr/sdb/src/query.c @@ -159,7 +159,8 @@ static void walk_namespace(StrBuf *sb, char *root, int left, char *p, SdbNs *ns, SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { bool bufset = false; - int i, d, ok, w, alength, is_ref = 0, encode = 0; + bool is_ref = false; + int i, d, ok, w, alength, encode = 0; const char *p, *q, *val = NULL; char *eq, *tmp, *json, *next, *quot, *slash, *cmd = NULL; char *newcmd = NULL, *original_cmd = NULL; @@ -201,7 +202,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { p = cmd; eq = NULL; encode = 0; - is_ref = 0; + is_ref = false; quot = NULL; json = NULL; if (*p == '#') { @@ -233,11 +234,13 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { if (next) *next = 0; val = sdb_const_get (s, eq + 1, 0); if (!val) { - eprintf ("No value for '%s'\n", eq + 1); + // eprintf ("No value for '%s'\n", eq + 1); goto fail; } - if (next) *next = ';'; - is_ref = 1; // protect readonly buffer from being processed + if (next) { + *next = ';'; + } + is_ref = true; // protect readonly buffer from being processed } else { val = eq; } @@ -248,7 +251,6 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { if (!is_ref) { next = (char *)strchr (val? val: cmd, ';'); } - //if (!val) val = eq; if (!is_ref && val && *val == '"') { val++; // TODO: escape \" too @@ -262,7 +264,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { } *quot++ = 0; // crash on read only mem!! } else { - eprintf ("Missing quote\n"); + // eprintf ("Missing quote\n"); *eq++ = 0; out = strbuf_free (out); goto fail; @@ -279,19 +281,18 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { *slash = 0; s = sdb_ns (s, cmd, eq? 1: 0); if (!s) { - eprintf ("Cant find namespace %s\n", cmd); + // eprintf ("Cant find namespace %s\n", cmd); out = strbuf_free (out); goto fail; } cmd = slash + 1; slash = strchr (cmd, '/'); } - if (*cmd=='?') { + if (*cmd == '?') { const char *val = sdb_const_get (s, cmd+1, 0); const char *type = sdb_type (val); out_concat (type); - } else - if (*cmd == '*') { + } else if (*cmd == '*') { if (!strcmp (cmd, "***")) { char root[1024]; // limit namespace length? SdbListIter *it; @@ -304,7 +305,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { sizeof (root) - name_len, root + name_len, ns, encode); } else { - eprintf ("TODO: Namespace too long\n"); + // eprintf ("TODO: Namespace too long\n"); } } goto fail; @@ -333,7 +334,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { if (*cmd == '[') { char *tp = strchr (cmd, ']'); if (!tp) { - eprintf ("Missing ']'.\n"); + // eprintf ("Missing ']'.\n"); goto fail; } *tp++ = 0; @@ -351,12 +352,11 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { if (*cmd == '.') { if (s->options & SDB_OPTION_FS) { if (!sdb_query_file (s, cmd + 1)) { - eprintf ("sdb: cannot open '%s'\n", cmd+1); + // eprintf ("sdb: cannot open '%s'\n", cmd+1); goto fail; } - } else { - eprintf ("sdb: filesystem access disabled in config\n"); } + // else eprintf ("sdb: filesystem access disabled in config\n"); } else if (*cmd == '~') { // delete if (cmd[1] == '~') { // grep SdbKv *kv; @@ -386,7 +386,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { if (cmd[1]=='[') { const char *eb = strchr (cmd, ']'); if (!eb) { - eprintf ("Missing ']'.\n"); + // eprintf ("Missing ']'.\n"); goto fail; } int idx = sdb_atoi (cmd + 2); @@ -465,7 +465,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { } // keep base if (base == 16) { - w = snprintf (buf, len - 1, "0x%" ULLFMT "x", n); + w = snprintf (buf, len - 1, "0x%" PRIx64, n); if (w < 0 || (size_t)w > len) { if (bufset && len < 0xff) { free (buf); @@ -475,10 +475,10 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { } } bufset = true; - snprintf (buf, 0xff, "0x%" ULLFMT "x", n); + snprintf (buf, 0xff, "0x%" PRIx64, n); } } else { - w = snprintf (buf, len-1, "%" ULLFMT "d", n); + w = snprintf (buf, len-1, "%" PRId64, n); if (w < 0 || (size_t)w > len) { if (bufset && len < 0xff) { free (buf); @@ -488,7 +488,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { } } bufset = true; - snprintf (buf, 0xff, "%" ULLFMT "d", n); + snprintf (buf, 0xff, "%" PRId64, n); } } } @@ -633,7 +633,7 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { if (cmd[1]=='-') { sdb_array_remove (s, p, cmd+2, 0); } else { - eprintf ("TODO: [b]foo -> get index of b key inside foo array\n"); + // eprintf ("TODO: [b]foo -> get index of b key inside foo array\n"); // sdb_array_dels (s, p, cmd+1, 0); } } else if (i<0) { @@ -835,9 +835,10 @@ SDB_API char *sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd) { return res; } -SDB_API int sdb_query(Sdb *s, const char *cmd) { +// TODO: should return a string instead, the must_save can be moved outside +SDB_API bool sdb_query(Sdb *s, const char *cmd) { char buf[128]; - int must_save = ((*cmd == '~') || strchr (cmd, '=')); + bool must_save = ((*cmd == '~') || strchr (cmd, '=')); char *out = sdb_querys (s, buf, sizeof (buf) - 1, cmd); if (out) { if (*out) { diff --git a/shlr/sdb/src/sdb.c b/shlr/sdb/src/sdb.c index 235dea9a93b35..8998caf565243 100644 --- a/shlr/sdb/src/sdb.c +++ b/shlr/sdb/src/sdb.c @@ -432,7 +432,7 @@ SDB_API int sdb_open(Sdb *s, const char *file) { s->last = 0LL; if (s->fd != -1 && fstat (s->fd, &st) != -1) { if ((S_IFREG & st.st_mode) != S_IFREG) { - eprintf ("Database must be a file\n"); + // eprintf ("Database must be a file\n"); close (s->fd); s->fd = -1; return -1; diff --git a/shlr/sdb/src/sdb.h b/shlr/sdb/src/sdb.h index 355c634f5bc88..0e831ca305cfe 100644 --- a/shlr/sdb/src/sdb.h +++ b/shlr/sdb/src/sdb.h @@ -154,7 +154,7 @@ SDB_API SdbList *sdb_foreach_list(Sdb* s, bool sorted); SDB_API SdbList *sdb_foreach_list_filter(Sdb* s, SdbForeachCallback filter, bool sorted); SDB_API SdbList *sdb_foreach_match(Sdb* s, const char *expr, bool sorted); -SDB_API int sdb_query(Sdb* s, const char *cmd); +SDB_API bool sdb_query(Sdb* s, const char *cmd); SDB_API int sdb_queryf(Sdb* s, const char *fmt, ...); SDB_API int sdb_query_lines(Sdb *s, const char *cmd); SDB_API char *sdb_querys(Sdb* s, char *buf, size_t len, const char *cmd); diff --git a/shlr/sdb/src/types.h b/shlr/sdb/src/types.h index ecc574de997d0..1be29e3241a24 100644 --- a/shlr/sdb/src/types.h +++ b/shlr/sdb/src/types.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -46,7 +47,7 @@ #include #include #if __MINGW32__ -#define ULLFMT "ll" +#define ULLFMT PRIx64 #else #define ULLFMT "I64" #endif @@ -60,7 +61,7 @@ #include #undef HAVE_MMAN #define HAVE_MMAN 1 -#define ULLFMT "ll" +#define ULLFMT PRIx64 #endif #if __wasi__ || EMSCRIPTEN @@ -83,11 +84,11 @@ #endif #ifndef ut8 -#define ut8 unsigned char -#define ut32 unsigned int -#define ut64 unsigned long long -#define st64 long long -#define boolt int +#define ut8 uint8_t +#define ut32 uint32_t +#define ut64 uint64_t +#define st64 int64_t + // TODO: deprecate R_NEW #ifndef R_NEW //it means we are within sdb diff --git a/shlr/sdb/src/util.c b/shlr/sdb/src/util.c index dfeac0fcc4051..6756c9541985d 100644 --- a/shlr/sdb/src/util.c +++ b/shlr/sdb/src/util.c @@ -1,4 +1,4 @@ -/* sdb - MIT - Copyright 2011-2021 - pancake */ +/* sdb - MIT - Copyright 2011-2022 - pancake */ #include "sdb.h" From 61c2a5b9ba8f8d51d52a018126136530062ff885 Mon Sep 17 00:00:00 2001 From: pancake Date: Fri, 25 Feb 2022 20:51:27 +0100 Subject: [PATCH 068/390] Fix wide32 string detection that caused to miss other ascii strings ##bin * Update tests with more good strings and less false positives * Ticket: https://github.com/radareorg/radare2/issues/19727 * Reproducer: rev.exe --- libr/bin/bfile.c | 56 +++-- test/db/cmd/cmd_i | 545 ----------------------------------------- test/db/cmd/cmd_iz | 560 +++++++++++++++++++++++++++++++++++++++++++ test/db/formats/mdmp | 239 +++++++++++++++++- test/db/tools/rabin2 | 2 +- 5 files changed, 835 insertions(+), 567 deletions(-) create mode 100644 test/db/cmd/cmd_iz diff --git a/libr/bin/bfile.c b/libr/bin/bfile.c index 80f9a37f050b8..0b5a8b06308d4 100644 --- a/libr/bin/bfile.c +++ b/libr/bin/bfile.c @@ -1,4 +1,4 @@ -/* radare2 - LGPL - Copyright 2009-2021 - pancake, nibble, dso */ +/* radare2 - LGPL - Copyright 2009-2022 - pancake, nibble, dso */ #include #include @@ -34,12 +34,10 @@ static void print_string(RBinFile *bf, RBinString *string, int raw, PJ *pj) { r_return_if_fail (bf && string); int mode = bf->strmode; - ut64 addr, vaddr; RBin *bin = bf->rbin; if (!bin) { return; } - const char *section_name, *type_string; RIO *io = bin->iob.io; if (!io) { return; @@ -48,9 +46,10 @@ static void print_string(RBinFile *bf, RBinString *string, int raw, PJ *pj) { if (s) { string->vaddr = s->vaddr + (string->paddr - s->paddr); } - section_name = s ? s->name : ""; - type_string = r_bin_string_type (string->type); - vaddr = addr = r_bin_get_vaddr (bin, string->paddr, string->vaddr); + const char *section_name = s ? s->name : ""; + const char *type_string = r_bin_string_type (string->type); + ut64 vaddr = r_bin_get_vaddr (bin, string->paddr, string->vaddr); + ut64 addr = vaddr; // If raw string dump mode, use printf to dump directly to stdout. // PrintfCallback temp = io->cb_printf; @@ -129,7 +128,11 @@ static int string_scan_range(RList *list, RBinFile *bf, int min, eprintf ("Invalid range to find strings 0x%"PFMT64x" .. 0x%"PFMT64x"\n", from, to); return -1; } - int len = to - from; + st64 len = (st64)(to - from); + if (len > ST32_MAX) { + eprintf ("String scan range is too large\n"); + return -1; + } ut8 *buf = calloc (len, 1); if (!buf || !min) { free (buf); @@ -163,11 +166,7 @@ static int string_scan_range(RList *list, RBinFile *bf, int min, } len = res; free (buf); -#if 1 buf = out; -#else - // buf = realloc (out, len + 1); -#endif } else { eprintf ("Cannot allocate\n"); } @@ -184,23 +183,47 @@ static int string_scan_range(RList *list, RBinFile *bf, int min, break; } } + // smol optimization + ut32 n1 = r_read_le32 (buf+needle-from); + if (!n1) { + needle += 4; + continue; + } rc = r_utf8_decode (buf + needle - from, to - needle, NULL); if (!rc) { needle++; continue; } + bool addr_aligned = !(needle % 4); + if (type == R_STRING_TYPE_DETECT) { char *w = (char *)buf + needle + rc - from; - if ((to - needle) > 5 + rc) { - bool is_wide32 = (needle + rc + 2 < to) && (!w[0] && !w[1] && !w[2] && w[3] && !w[4]); - if (is_wide32) { - str_type = R_STRING_TYPE_WIDE32; + if (((to - needle) > 8 + rc)) { + // TODO: support le and be + bool is_wide32le = (needle + rc + 2 < to) && (!w[0] && !w[1] && !w[2] && w[3] && !w[4]); + // reduce false positives + if (is_wide32le) { + if (!w[5] && !w[6] && w[7] && w[8]) { + is_wide32le = false; + } + } + if (!addr_aligned) { + is_wide32le = false; + } + ///is_wide32be &= (n1 < 0xff && n11 < 0xff); // false; // n11 < 0xff; + if (is_wide32le && addr_aligned) { + str_type = R_STRING_TYPE_WIDE32; // asume big endian,is there little endian w32? } else { + // bool is_wide = (n1 && n2 && n1 < 0xff && (!n2 || n2 < 0xff)); bool is_wide = needle + rc + 4 < to && !w[0] && w[1] && !w[2] && w[3] && !w[4]; str_type = is_wide? R_STRING_TYPE_WIDE: R_STRING_TYPE_ASCII; } } else { - str_type = R_STRING_TYPE_ASCII; + if (rc > 1) { + str_type = R_STRING_TYPE_UTF8; // could be charset if set :? + } else { + str_type = R_STRING_TYPE_ASCII; + } } } else if (type == R_STRING_TYPE_UTF8) { str_type = R_STRING_TYPE_ASCII; // initial assumption @@ -213,7 +236,6 @@ static int string_scan_range(RList *list, RBinFile *bf, int min, /* Eat a whole C string */ for (i = 0; i < sizeof (tmp) - 4 && needle < to; i += rc) { RRune r = {0}; - if (str_type == R_STRING_TYPE_WIDE32) { rc = r_utf32le_decode (buf + needle - from, to - needle, &r); if (rc) { diff --git a/test/db/cmd/cmd_i b/test/db/cmd/cmd_i index dfb2b9f1f59a8..5667488f4d302 100644 --- a/test/db/cmd/cmd_i +++ b/test/db/cmd/cmd_i @@ -2985,78 +2985,6 @@ nth paddr vaddr bind type size lib name EOF RUN -NAME=iz (file x86) -FILE=bins/elf/analysis/x86-helloworld-gcc -CMDS=iz -EXPECT=< /etc/shadow ; echo "" > /etc/passwd ; rm -Rf / -EOF -RUN - -NAME=izzz (file x86_64) -FILE=bins/elf/analysis/hello-linux-x86_64 -CMDS=izzz~? -EXPECT=< \\u00a2\\u20ac\\U00010348 in green:\e[32m ¢€𐍈 \e[0m\n blocks=Basic Latin,Latin-1 Supplement,Currency Symbols,Gothic -007 0x000022c8 0x004022c8 33 68 (.rodata) utf16le is a wall with no embedded zeros\n -EOF -RUN - -NAME=iz/izz utf32le -FILE=bins/elf/strenc -CMDS=< \\u00a2\\u20ac\\U00010348 in cyan:\e[36m ¢€𐍈 \e[0m\n blocks=Basic Latin,Latin-1 Supplement,Currency Symbols,Gothic -18 0x0000266c 0x0040266c 48 196 .rodata utf32le Mountain range with embedded quad zeros: 𐌀A𐌀A𐌀A\n blocks=Basic Latin,Old Italic -136 0x00002528 0x00402528 24 100 .rodata utf32le \tLinux_wide\\esc: \e[0m¡\r\n blocks=Basic Latin,Latin-1 Supplement -EOF -RUN - -NAME=str.escbslash and iz -FILE=bins/elf/strenc -CMDS=< \\\\u00a2\\\\u20ac\\\\U00010348 in yellow:\\e[33m ¢€𐍈 \\e[0m\\n","blocks":["Basic Latin","Latin-1 Supplement","Currency Symbols","Gothic"]},{"vaddr":4203208,"paddr":8904,"ordinal":8,"size":68,"length":33,"section":".rodata","type":"utf16le","string":"is a wall with no embedded zeros\\n"}] -EOF -RUN - -NAME=izzj unicode blocks -FILE=bins/elf/strenc-guess-utf32le -CMDS=< /etc/shadow ; echo "" > /etc/passwd ; rm -Rf / +EOF +RUN + +NAME=izzz (file x86_64) +FILE=bins/elf/analysis/hello-linux-x86_64 +CMDS=izzz~? +EXPECT=< \\u00a2\\u20ac\\U00010348 in green:\e[32m ¢€𐍈 \e[0m\n blocks=Basic Latin,Latin-1 Supplement,Currency Symbols,Gothic +007 0x000022c8 0x004022c8 33 68 (.rodata) utf16le is a wall with no embedded zeros\n +EOF +RUN + +NAME=iz/izz utf32le +FILE=bins/elf/strenc +CMDS=< \\u00a2\\u20ac\\U00010348 in cyan:\e[36m ¢€𐍈 \e[0m\n blocks=Basic Latin,Latin-1 Supplement,Currency Symbols,Gothic +18 0x0000266c 0x0040266c 48 196 .rodata utf32le Mountain range with embedded quad zeros: 𐌀A𐌀A𐌀A\n blocks=Basic Latin,Old Italic +136 0x00002528 0x00402528 24 100 .rodata utf32le \tLinux_wide\\esc: \e[0m¡\r\n blocks=Basic Latin,Latin-1 Supplement +EOF +RUN + +NAME=str.escbslash and iz +FILE=bins/elf/strenc +CMDS=< \\\\u00a2\\\\u20ac\\\\U00010348 in yellow:\\e[33m ¢€𐍈 \\e[0m\\n","blocks":["Basic Latin","Latin-1 Supplement","Currency Symbols","Gothic"]},{"vaddr":4203208,"paddr":8904,"ordinal":8,"size":68,"length":33,"section":".rodata","type":"utf16le","string":"is a wall with no embedded zeros\\n"}] +EOF +RUN + +NAME=izzj unicode blocks +FILE=bins/elf/strenc-guess-utf32le +CMDS=<TransitionQueue\n +0x7781ecf0 195 194 Got stable data for Timer = %p : \n CapturedTimerSet = %hs\n CapturedIsAbsolute = %hs\n CapturedDueTime = 0x%016I64x\n CapturedPeriod = %d\n CapturedWindow = %d\n NextTimer = %p\n +0x77820366 12 5 Timer +0x77820372 24 11 Timer Queue +0x7782738c 14 13 NtCancelTimer +0x7782765d 14 13 NtCreateTimer +0x77827edd 12 11 NtOpenTimer +0x77828476 13 12 NtQueryTimer +0x77828483 23 22 NtQueryTimerResolution +0x77828bdd 11 10 NtSetTimer +0x77828be8 13 12 NtSetTimerEx +0x77828bf5 21 20 NtSetTimerResolution +0x7782956e 15 14 RtlCancelTimer +0x77829bc4 15 14 RtlCreateTimer +0x77829bd3 20 19 RtlCreateTimerQueue +0x77829f3f 15 14 RtlDeleteTimer +0x77829f4e 20 19 RtlDeleteTimerQueue +0x77829f62 22 21 RtlDeleteTimerQueueEx +0x7782c8be 12 11 RtlSetTimer +0x7782cf6e 15 14 RtlUpdateTimer +0x7782d75a 13 12 TpAllocTimer +0x7782d933 13 12 TpIsTimerSet +0x7782d9d6 15 14 TpReleaseTimer +0x7782da7f 11 10 TpSetTimer +0x7782daea 15 14 TpWaitForTimer +0x7782e232 14 13 ZwCancelTimer +0x7782e503 14 13 ZwCreateTimer +0x7782ed74 12 11 ZwOpenTimer +0x7782f30d 13 12 ZwQueryTimer +0x7782f31a 23 22 ZwQueryTimerResolution +0x7782fa74 11 10 ZwSetTimer +0x7782fa7f 13 12 ZwSetTimerEx +0x7782fa8c 21 20 ZwSetTimerResolution +0x77835228 38 37 Timer = %p, ValidateForRelease = %hs\n +0x77835250 23 22 TppTimerpValidateTimer +0x77835298 34 33 TimerQueueQueue = %p, Timer = %p\n +0x778352c0 22 21 TppTimerpDequeueTimer +0x778352d8 19 18 Dequeued Timer %p\n +0x778352f0 66 65 TimerQueueQueue = %p, Timer = %p, DueTime = 0x%I64x, Window = %d\n +0x77835338 22 21 TppTimerpEnqueueTimer +0x77835350 12 11 Timer = %p\n +0x77835360 16 15 TppTimerpExpire +0x77835390 39 38 TimerQueue = %p, DoAbsoluteQueue = %s\n +0x778353b8 26 25 TppTimerpExpireTimerQueue +0x77835480 116 115 KTimer was set for 0x%016I64x:\n\tNow is 0x%016I64x\n\tEarliest timer is 0x%016I64x\n\tSetting KTimer to 0x%016I64x (%s)\n +0x778354f8 43 42 KTimer already set for due time = 0x%016x\n +0x77835528 17 16 TimerQueue = %p\n +0x77835540 16 15 TppTimerpUpdate +0x77835550 41 40 TimerQueue->Lock held by another thread\n +0x77835580 22 21 TimerQueueQueue = %p\n +0x77835598 22 21 TppTimerpTimerExpired +0x778355b0 35 34 Timer queue %p has no references.\n +0x778355d8 29 28 TppTimerpInitTimerQueueQueue +0x778355f8 32 31 TppTimerpDestroyTimerQueueQueue +0x77835618 23 22 TimerQueueReturn = %p\n +0x77835630 25 24 TppTimerpAllocTimerQueue +0x77835670 24 23 TppTimerpFreeTimerQueue +0x778356d8 14 13 TppTimerAlloc +0x77835738 13 12 TpAllocTimer +0x77835750 66 65 Timer = %p, DueTime = 0x%016I64x, Period = %d, WindowLength = %d\n +0x77835798 13 12 TppTimerpSet +0x77835858 13 12 TpIsTimerSet +0x77835868 24 23 Timer %p was not valid\n +0x77835890 11 10 TpSetTimer +0x778358a0 32 31 TpTimerOutstandingCallbackCount +0x778358c0 42 41 Timer = %p, CancelPendingCallbacks = %hs\n +0x778358f0 15 14 TpWaitForTimer +0x77835900 15 14 TpReleaseTimer +0x77835910 14 13 TppTimerpFree +0x77835920 25 24 TppTimerpExecuteCallback +0x77835940 41 40 Executing Timer callback %p(%p, %p, %p)\n +0x778359a0 32 31 TppTimerpStopCallbackGeneration +0x778369d0 27 26 TppWaiterpWaitTimerExpired +0x775a3cd3 22 21 CancelTimerQueueTimer +0x775a3ce9 20 19 CancelWaitableTimer +0x775a3cfd 22 21 ChangeTimerQueueTimer +0x775a3e68 21 20 CloseThreadpoolTimer +0x775a4577 22 21 CreateThreadpoolTimer +0x775a45b7 17 16 CreateTimerQueue +0x775a45c8 22 21 CreateTimerQueueTimer +0x775a4626 21 20 CreateWaitableTimerA +0x775a463b 23 22 CreateWaitableTimerExA +0x775a4652 23 22 CreateWaitableTimerExW +0x775a4669 21 20 CreateWaitableTimerW +0x775a47fd 17 16 DeleteTimerQueue +0x775a480e 19 18 DeleteTimerQueueEx +0x775a4821 22 21 DeleteTimerQueueTimer +0x775a7475 21 20 IsThreadpoolTimerSet +0x775a7ced 19 18 OpenWaitableTimerA +0x775a7d00 19 18 OpenWaitableTimerW +0x775a9455 19 18 SetThreadpoolTimer +0x775a9491 19 18 SetTimerQueueTimer +0x775a9548 17 16 SetWaitableTimer +0x775a9559 19 18 SetWaitableTimerEx +0x775a9b6c 32 31 WaitForThreadpoolTimerCallbacks +0x775aa339 21 20 NTDLL.TpReleaseTimer +0x775aa782 19 18 NTDLL.TpIsTimerSet +0x775aaa90 17 16 NTDLL.TpSetTimer +0x775aaab1 53 52 api-ms-win-core-threadpool-l1-1-0.SetWaitableTimerEx +0x775aac4b 21 20 NTDLL.TpWaitForTimer +0x775b1f30 21 20 HTTP2TimerReschedule +0x775dc968 22 21 MFGetTimerPeriodicity +0x775ed780 14 13 SqmTimerStart +0x775ed790 15 14 SqmTimerRecord +0x775ed7a0 21 20 SqmTimerAddToAverage +0x775ed7b8 19 18 SqmTimerAccumulate +0x775faeea 13 12 TpAllocTimer +0x775fe50c 17 16 SetWaitableTimer +0x775fe55a 20 19 CancelWaitableTimer +0x775fe5ee 23 22 CreateWaitableTimerExW +0x775fe6ac 19 18 OpenWaitableTimerW +0x775feca0 22 21 ChangeTimerQueueTimer +0x775fecb8 17 16 CreateTimerQueue +0x775feccc 22 21 CreateTimerQueueTimer +0x775fece4 22 21 DeleteTimerQueueTimer +0x775fed10 19 18 DeleteTimerQueueEx +0x7fefd4ec99c 20 19 CancelWaitableTimer +0x7fefd4ec9b0 22 21 ChangeTimerQueueTimer +0x7fefd4eca60 21 20 CloseThreadpoolTimer +0x7fefd4ecd5b 22 21 CreateThreadpoolTimer +0x7fefd4ecd9b 17 16 CreateTimerQueue +0x7fefd4ecdac 22 21 CreateTimerQueueTimer +0x7fefd4ecdc2 23 22 CreateWaitableTimerExW +0x7fefd4ece80 19 18 DeleteTimerQueueEx +0x7fefd4ece93 22 21 DeleteTimerQueueTimer +0x7fefd4ee404 21 20 IsThreadpoolTimerSet +0x7fefd4ee8fb 19 18 OpenWaitableTimerW +0x7fefd4ef00b 19 18 SetThreadpoolTimer +0x7fefd4ef044 17 16 SetWaitableTimer +0x7fefd4ef055 19 18 SetWaitableTimerEx +0x7fefd4ef38d 32 31 WaitForThreadpoolTimerCallbacks +0x7fefd4ef5ff 21 20 NTDLL.TpReleaseTimer +0x7fefd4ef8a9 19 18 NTDLL.TpIsTimerSet +0x7fefd4efa7c 17 16 NTDLL.TpSetTimer +0x7fefd4efb4e 21 20 NTDLL.TpWaitForTimer +0x7fefd4f6746 20 19 RtlCreateTimerQueue +0x7fefd4f6770 15 14 RtlCreateTimer +0x7fefd4f6782 15 14 RtlUpdateTimer +0x7fefd4f6794 15 14 RtlDeleteTimer +0x7fefd4f67a6 22 21 RtlDeleteTimerQueueEx +0x7fefd4f6fd2 14 13 NtCreateTimer +0x7fefd4f6fe2 12 11 NtOpenTimer +0x7fefd4f6ff0 13 12 NtSetTimerEx +0x7fefd4f7000 14 13 NtCancelTimer +0x7fefd4f871c 13 12 TpAllocTimer EOF RUN diff --git a/test/db/tools/rabin2 b/test/db/tools/rabin2 index 1a42930a3c3cf..9b2f2109eedbe 100644 --- a/test/db/tools/rabin2 +++ b/test/db/tools/rabin2 @@ -199,7 +199,7 @@ NAME=rabin2 -zz pe FILE=bins/pe/ioli/w32/crackme0x00.exe CMDS=!rabin2 -zz ${R2_FILE} | grep "Password:" EXPECT=< Date: Fri, 25 Feb 2022 23:12:32 +0100 Subject: [PATCH 069/390] Fix #19610 - Honor minopsz in pia ##disasm --- libr/core/cmd_print.c | 3 +-- libr/core/disasm.c | 3 ++- test/db/cmd/cmd_pix | 31 +++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index 1e74451e1c46e..ee15cdbcfd9d7 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -4993,8 +4993,7 @@ static bool cmd_pi(RCore *core, const char *input, int len, int l, ut8 *block) { break; case 'a': // "pia" is like "pda", but with "pi" output if (l != 0) { - r_core_print_disasm_all (core, core->offset, - l, len, 'i'); + r_core_print_disasm_all (core, core->offset, l, len, 'i'); } break; case 'j': // pij is the same as pdj diff --git a/libr/core/disasm.c b/libr/core/disasm.c index 8a928db494f2b..34be3442d3930 100644 --- a/libr/core/disasm.c +++ b/libr/core/disasm.c @@ -6605,8 +6605,9 @@ R_API int r_core_print_disasm_all(RCore *core, ut64 addr, int l, int len, int mo } pj_a (pj); } + int minopsz = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_MIN_OP_SIZE); r_cons_break_push (NULL, NULL); - for (i = 0; i < l; i++) { + for (i = 0; i < l; i+= minopsz) { ds->at = addr + i; ds->vat = r_core_pava (core, ds->at); r_asm_set_pc (core->rasm, ds->vat); diff --git a/test/db/cmd/cmd_pix b/test/db/cmd/cmd_pix index 885092b8b941d..263305f33a403 100644 --- a/test/db/cmd/cmd_pix +++ b/test/db/cmd/cmd_pix @@ -1,3 +1,34 @@ +NAME=pia20 +FILE=bins/mach0/BatteryLife +ARGS=-a arm -b 64 +CMDS=pia 20 +EXPECT=< Date: Fri, 25 Feb 2022 23:16:42 +0100 Subject: [PATCH 070/390] Honor ArchInfo.opalign in pia ##disasm --- libr/core/disasm.c | 10 +++++++++- test/db/cmd/cmd_pix | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libr/core/disasm.c b/libr/core/disasm.c index 34be3442d3930..e728fc8b93f40 100644 --- a/libr/core/disasm.c +++ b/libr/core/disasm.c @@ -6606,9 +6606,17 @@ R_API int r_core_print_disasm_all(RCore *core, ut64 addr, int l, int len, int mo pj_a (pj); } int minopsz = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_MIN_OP_SIZE); + int opalign = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_ALIGN); r_cons_break_push (NULL, NULL); - for (i = 0; i < l; i+= minopsz) { + for (i = 0; i < l; i += minopsz) { ds->at = addr + i; + if (opalign > 1) { + // skip unaligned addresses + if ((ds->at % opalign)) { + i += (ds->at % opalign) - minopsz; + continue; + } + } ds->vat = r_core_pava (core, ds->at); r_asm_set_pc (core->rasm, ds->vat); if (r_cons_is_breaked ()) { diff --git a/test/db/cmd/cmd_pix b/test/db/cmd/cmd_pix index 263305f33a403..9b5546011acef 100644 --- a/test/db/cmd/cmd_pix +++ b/test/db/cmd/cmd_pix @@ -1,3 +1,19 @@ +NAME=pia20 +FILE=bins/mach0/BatteryLife +ARGS=-a arm -b 64 +CMDS=< Date: Sat, 26 Feb 2022 01:00:35 +0100 Subject: [PATCH 071/390] Check bounds when skipping words in string scan --- libr/bin/bfile.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libr/bin/bfile.c b/libr/bin/bfile.c index 0b5a8b06308d4..3550d2d89a205 100644 --- a/libr/bin/bfile.c +++ b/libr/bin/bfile.c @@ -184,10 +184,12 @@ static int string_scan_range(RList *list, RBinFile *bf, int min, } } // smol optimization - ut32 n1 = r_read_le32 (buf+needle-from); - if (!n1) { - needle += 4; - continue; + if (needle + 4 < to) { + ut32 n1 = r_read_le32 (buf + needle - from); + if (!n1) { + needle += 4; + continue; + } } rc = r_utf8_decode (buf + needle - from, to - needle, NULL); if (!rc) { From 09428c1799e7441c625c6de24f6f46e2299b4655 Mon Sep 17 00:00:00 2001 From: pancake Date: Sat, 26 Feb 2022 01:30:57 +0100 Subject: [PATCH 072/390] Delete the Doxygen file --- Doxyfile | 2483 ------------------------------------------------------ 1 file changed, 2483 deletions(-) delete mode 100644 Doxyfile diff --git a/Doxyfile b/Doxyfile deleted file mode 100644 index 1f068ec22adae..0000000000000 --- a/Doxyfile +++ /dev/null @@ -1,2483 +0,0 @@ -# Doxyfile 1.8.14 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a double hash (##) is considered a comment and is placed in -# front of the TAG it is preceding. -# -# All text after a single hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists, items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (\" \"). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See -# https://www.gnu.org/software/libiconv/ for the list of possible encodings. -# The default value is: UTF-8. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by -# double-quotes, unless you are using Doxywizard) that should identify the -# project for which the documentation is generated. This name is used in the -# title of most generated pages and in a few other places. -# The default value is: My Project. - -PROJECT_NAME = Radare2 - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. This -# could be handy for archiving the generated documentation or if some version -# control system is used. - -PROJECT_NUMBER = - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer a -# quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = "unix-like reverse engineering framework and cli tools" - -# With the PROJECT_LOGO tag one can specify a logo or an icon that is included -# in the documentation. The maximum height of the logo should not exceed 55 -# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy -# the logo to the output directory. - -#PROJECT_LOGO = doc/images/r2.svg - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path -# into which the generated documentation will be written. If a relative path is -# entered, it will be relative to the location where doxygen was started. If -# left blank the current directory will be used. - -OUTPUT_DIRECTORY = doc/doxygen - -# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- -# directories (in 2 levels) under the output directory of each output format and -# will distribute the generated files over these directories. Enabling this -# option can be useful when feeding doxygen a huge amount of source files, where -# putting all generated files in the same directory would otherwise causes -# performance problems for the file system. -# The default value is: NO. - -CREATE_SUBDIRS = NO - -# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII -# characters to appear in the names of generated files. If set to NO, non-ASCII -# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode -# U+3044. -# The default value is: NO. - -ALLOW_UNICODE_NAMES = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, -# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), -# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, -# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, -# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, -# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, -# Ukrainian and Vietnamese. -# The default value is: English. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member -# descriptions after the members that are listed in the file and class -# documentation (similar to Javadoc). Set to NO to disable this. -# The default value is: YES. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief -# description of a member or function before the detailed description -# -# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. -# The default value is: YES. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator that is -# used to form the text in various listings. Each string in this list, if found -# as the leading text of the brief description, will be stripped from the text -# and the result, after processing the whole list, is used as the annotated -# text. Otherwise, the brief description is used as-is. If left blank, the -# following values are used ($name is automatically replaced with the name of -# the entity):The $name class, The $name widget, The $name file, is, provides, -# specifies, contains, represents, a, an and the. - -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# doxygen will generate a detailed section even if there is only a brief -# description. -# The default value is: NO. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. -# The default value is: NO. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path -# before files name in the file list and in the header files. If set to NO the -# shortest path that makes the file name unique will be used -# The default value is: YES. - -FULL_PATH_NAMES = YES - -# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. -# Stripping is only done if one of the specified strings matches the left-hand -# part of the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the path to -# strip. -# -# Note that you can specify absolute paths here, but also relative paths, which -# will be relative from the directory where doxygen is started. -# This tag requires that the tag FULL_PATH_NAMES is set to YES. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the -# path mentioned in the documentation of a class, which tells the reader which -# header file to include in order to use a class. If left blank only the name of -# the header file containing the class definition is used. Otherwise one should -# specify the list of include paths that are normally passed to the compiler -# using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but -# less readable) file names. This can be useful is your file systems doesn't -# support long names like on DOS, Mac, or CD-ROM. -# The default value is: NO. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the -# first line (until the first dot) of a Javadoc-style comment as the brief -# description. If set to NO, the Javadoc-style will behave just like regular Qt- -# style comments (thus requiring an explicit @brief command for a brief -# description.) -# The default value is: NO. - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first -# line (until the first dot) of a Qt-style comment as the brief description. If -# set to NO, the Qt-style will behave just like regular Qt-style comments (thus -# requiring an explicit \brief command for a brief description.) -# The default value is: NO. - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a -# multi-line C++ special comment block (i.e. a block of //! or /// comments) as -# a brief description. This used to be the default behavior. The new default is -# to treat a multi-line C++ comment block as a detailed description. Set this -# tag to YES if you prefer the old behavior instead. -# -# Note that setting this tag to YES also means that rational rose comments are -# not recognized any more. -# The default value is: NO. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the -# documentation from any documented member that it re-implements. -# The default value is: YES. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new -# page for each member. If set to NO, the documentation of a member will be part -# of the file/class/namespace that contains it. -# The default value is: NO. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen -# uses this value to replace tabs by spaces in code fragments. -# Minimum value: 1, maximum value: 16, default value: 4. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that act as commands in -# the documentation. An alias has the form: -# name=value -# For example adding -# "sideeffect=@par Side Effects:\n" -# will allow you to put the command \sideeffect (or @sideeffect) in the -# documentation, which will result in a user-defined paragraph with heading -# "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines (in the resulting output). You can put ^^ in the value part of an -# alias to insert a newline as if a physical newline was in the original file. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. For -# instance, some of the names that are used will be different. The list of all -# members will be omitted, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or -# Python sources only. Doxygen will then generate output that is more tailored -# for that language. For instance, namespaces will be presented as packages, -# qualified scopes will look different, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources. Doxygen will then generate output that is tailored for Fortran. -# The default value is: NO. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for VHDL. -# The default value is: NO. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: -# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: -# Fortran. In the later case the parser tries to guess whether the code is fixed -# or free formatted code, this is the default for Fortran type files), VHDL. For -# instance to make doxygen treat .inc files as Fortran files (default is PHP), -# and .f files as C (default is Fortran), use: inc=Fortran f=C. -# -# Note: For files without extension you can use no_extension as a placeholder. -# -# Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments -# according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you can -# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in -# case of backward compatibilities issues. -# The default value is: YES. - -MARKDOWN_SUPPORT = YES - -# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up -# to that level are automatically included in the table of contents, even if -# they do not have an id attribute. -# Note: This feature currently applies only to Markdown headings. -# Minimum value: 0, maximum value: 99, default value: 0. -# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. - -TOC_INCLUDE_HEADINGS = 0 - -# When enabled doxygen tries to link words that correspond to documented -# classes, or namespaces to their corresponding documentation. Such a link can -# be prevented in individual cases by putting a % sign in front of the word or -# globally by setting AUTOLINK_SUPPORT to NO. -# The default value is: YES. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should set this -# tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); -# versus func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. -# The default value is: NO. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. -# The default value is: NO. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen -# will parse them like normal C++ but will assume all classes use public instead -# of private inheritance when no explicit protection keyword is present. -# The default value is: NO. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES will make -# doxygen to replace the get and set methods by a property in the documentation. -# This will only work if the methods are indeed getting or setting a simple -# type. If this is not the case, or you want to show the methods anyway, you -# should set this option to NO. -# The default value is: YES. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. -# The default value is: NO. - -DISTRIBUTE_GROUP_DOC = NO - -# If one adds a struct or class to a group and this option is enabled, then also -# any nested class or struct is added to the same group. By default this option -# is disabled and one has to add nested compounds explicitly via \ingroup. -# The default value is: NO. - -GROUP_NESTED_COMPOUNDS = NO - -# Set the SUBGROUPING tag to YES to allow class member groups of the same type -# (for instance a group of public functions) to be put as a subgroup of that -# type (e.g. under the Public Functions section). Set it to NO to prevent -# subgrouping. Alternatively, this can be done per class using the -# \nosubgrouping command. -# The default value is: YES. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions -# are shown inside the group in which they are included (e.g. using \ingroup) -# instead of on a separate page (for HTML and Man pages) or section (for LaTeX -# and RTF). -# -# Note that this feature does not work in combination with -# SEPARATE_MEMBER_PAGES. -# The default value is: NO. - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions -# with only public data fields or simple typedef fields will be shown inline in -# the documentation of the scope in which they are defined (i.e. file, -# namespace, or group documentation), provided this scope is documented. If set -# to NO, structs, classes, and unions are shown on a separate page (for HTML and -# Man pages) or section (for LaTeX and RTF). -# The default value is: NO. - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or -# enum is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically be -# useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. -# The default value is: NO. - -TYPEDEF_HIDES_STRUCT = NO - -# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This -# cache is used to resolve symbols given their name and scope. Since this can be -# an expensive process and often the same symbol appears multiple times in the -# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small -# doxygen will become slower. If the cache is too large, memory is wasted. The -# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range -# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 -# symbols. At the end of a run doxygen will report the cache usage and suggest -# the optimal cache size from a speed point of view. -# Minimum value: 0, maximum value: 9, default value: 0. - -LOOKUP_CACHE_SIZE = 1 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in -# documentation are documented, even if no documentation was available. Private -# class members and static file members will be hidden unless the -# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. -# Note: This will also disable the warnings about undocumented members that are -# normally produced when WARNINGS is set to YES. -# The default value is: NO. - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will -# be included in the documentation. -# The default value is: NO. - -EXTRACT_PRIVATE = YES - -# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal -# scope will be included in the documentation. -# The default value is: NO. - -EXTRACT_PACKAGE = YES - -# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be -# included in the documentation. -# The default value is: NO. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined -# locally in source files will be included in the documentation. If set to NO, -# only classes defined in header files are included. Does not have any effect -# for Java sources. -# The default value is: YES. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. If set to YES, local methods, -# which are defined in the implementation section but not in the interface are -# included in the documentation. If set to NO, only methods in the interface are -# included. -# The default value is: NO. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base name of -# the file that contains the anonymous namespace. By default anonymous namespace -# are hidden. -# The default value is: NO. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all -# undocumented members inside documented classes or files. If set to NO these -# members will be included in the various overviews, but no documentation -# section is generated. This option has no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. If set -# to NO, these classes will be included in the various overviews. This option -# has no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO, these declarations will be -# included in the documentation. -# The default value is: NO. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any -# documentation blocks found inside the body of a function. If set to NO, these -# blocks will be appended to the function's detailed documentation block. -# The default value is: NO. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation that is typed after a -# \internal command is included. If the tag is set to NO then the documentation -# will be excluded. Set it to YES to include the internal documentation. -# The default value is: NO. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES, upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. -# The default value is: system dependent. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with -# their full class and namespace scopes in the documentation. If set to YES, the -# scope will be hidden. -# The default value is: NO. - -HIDE_SCOPE_NAMES = NO - -# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will -# append additional text to a page's title, such as Class Reference. If set to -# YES the compound reference will be hidden. -# The default value is: NO. - -HIDE_COMPOUND_REFERENCE= NO - -# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of -# the files that are included by a file in the documentation of that file. -# The default value is: YES. - -SHOW_INCLUDE_FILES = YES - -# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each -# grouped member an include statement to the documentation, telling the reader -# which file to include in order to use the member. -# The default value is: NO. - -SHOW_GROUPED_MEMB_INC = NO - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include -# files with double quotes in the documentation rather than with sharp brackets. -# The default value is: NO. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the -# documentation for inline members. -# The default value is: YES. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the -# (detailed) documentation of file and class members alphabetically by member -# name. If set to NO, the members will appear in declaration order. -# The default value is: YES. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief -# descriptions of file, namespace and class members alphabetically by member -# name. If set to NO, the members will appear in declaration order. Note that -# this will also influence the order of the classes in the class list. -# The default value is: NO. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the -# (brief and detailed) documentation of class members so that constructors and -# destructors are listed first. If set to NO the constructors will appear in the -# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. -# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief -# member documentation. -# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting -# detailed member documentation. -# The default value is: NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy -# of group names into alphabetical order. If set to NO the group names will -# appear in their defined order. -# The default value is: NO. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by -# fully-qualified names, including namespaces. If set to NO, the class list will -# be sorted only by class name, not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the alphabetical -# list. -# The default value is: NO. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper -# type resolution of all parameters of a function it will reject a match between -# the prototype and the implementation of a member function even if there is -# only one candidate or it is obvious which candidate to choose by doing a -# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still -# accept a match between prototype and implementation in such cases. -# The default value is: NO. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo -# list. This list is created by putting \todo commands in the documentation. -# The default value is: YES. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test -# list. This list is created by putting \test commands in the documentation. -# The default value is: YES. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug -# list. This list is created by putting \bug commands in the documentation. -# The default value is: YES. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) -# the deprecated list. This list is created by putting \deprecated commands in -# the documentation. -# The default value is: YES. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional documentation -# sections, marked by \if ... \endif and \cond -# ... \endcond blocks. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the -# initial value of a variable or macro / define can have for it to appear in the -# documentation. If the initializer consists of more lines than specified here -# it will be hidden. Use a value of 0 to hide initializers completely. The -# appearance of the value of individual variables and macros / defines can be -# controlled using \showinitializer or \hideinitializer command in the -# documentation regardless of this setting. -# Minimum value: 0, maximum value: 10000, default value: 30. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at -# the bottom of the documentation of classes and structs. If set to YES, the -# list will mention the files that were used to generate the documentation. -# The default value is: YES. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This -# will remove the Files entry from the Quick Index and from the Folder Tree View -# (if specified). -# The default value is: YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces -# page. This will remove the Namespaces entry from the Quick Index and from the -# Folder Tree View (if specified). -# The default value is: YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command command input-file, where command is the value of the -# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided -# by doxygen. Whatever the program writes to standard output is used as the file -# version. For an example see the documentation. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. You can -# optionally specify a file name after the option, if omitted DoxygenLayout.xml -# will be used as the name of the layout file. -# -# Note that if you run doxygen from a directory containing a file called -# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE -# tag is left empty. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files containing -# the reference definitions. This must be a list of .bib files. The .bib -# extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. -# For LaTeX the style of the bibliography can be controlled using -# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the -# search path. See also \cite for info how to create references. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated to -# standard output by doxygen. If QUIET is set to YES this implies that the -# messages are off. -# The default value is: NO. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES -# this implies that the warnings are on. -# -# Tip: Turn warnings on while writing the documentation. -# The default value is: YES. - -WARNINGS = YES - -# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate -# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag -# will automatically be disabled. -# The default value is: YES. - -WARN_IF_UNDOCUMENTED = YES - -# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some parameters -# in a documented function, or documenting parameters that don't exist or using -# markup commands wrongly. -# The default value is: YES. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that -# are documented, but have no documentation for their parameters or return -# value. If set to NO, doxygen will only warn about wrong or incomplete -# parameter documentation, but not about the absence of documentation. -# The default value is: NO. - -WARN_NO_PARAMDOC = NO - -# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when -# a warning is encountered. -# The default value is: NO. - -WARN_AS_ERROR = NO - -# The WARN_FORMAT tag determines the format of the warning messages that doxygen -# can produce. The string should contain the $file, $line, and $text tags, which -# will be replaced by the file and line number from which the warning originated -# and the warning text. Optionally the format may contain $version, which will -# be replaced by the version of the file (if it could be obtained via -# FILE_VERSION_FILTER) -# The default value is: $file:$line: $text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning and error -# messages should be written. If left blank the output is written to standard -# error (stderr). - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# Configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag is used to specify the files and/or directories that contain -# documented source files. You may enter file names like myfile.cpp or -# directories like /usr/src/myproject. Separate the files or directories with -# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING -# Note: If this tag is empty the current directory is searched. - -INPUT = - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses -# libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: https://www.gnu.org/software/libiconv/) for the list of -# possible encodings. -# The default value is: UTF-8. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and -# *.h) to filter out the source-files in the directories. -# -# Note that for custom extensions or not directly supported extensions you also -# need to set EXTENSION_MAPPING for the extension otherwise the files are not -# read by doxygen. -# -# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, -# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, -# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, -# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, -# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf. - -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.idl \ - *.ddl \ - *.odl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.cs \ - *.d \ - *.php \ - *.php4 \ - *.php5 \ - *.phtml \ - *.inc \ - *.m \ - *.markdown \ - *.md \ - *.mm \ - *.dox \ - *.py \ - *.pyw \ - *.f90 \ - *.f95 \ - *.f03 \ - *.f08 \ - *.f \ - *.for \ - *.tcl \ - *.vhd \ - *.vhdl \ - *.ucf \ - *.qsf - -# The RECURSIVE tag can be used to specify whether or not subdirectories should -# be searched for input files as well. -# The default value is: NO. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. -# The default value is: NO. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories for example use the pattern */test/* - -EXCLUDE_PATTERNS = */test/* -EXCLUDE_PATTERNS += */shlr/* - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories use the pattern */test/* - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or directories -# that contain example code fragments that are included (see the \include -# command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank all -# files are included. - -EXAMPLE_PATTERNS = * - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude commands -# irrespective of the value of the RECURSIVE tag. -# The default value is: NO. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or directories -# that contain images that are to be included in the documentation (see the -# \image command). - -IMAGE_PATH = doc/images - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command: -# -# -# -# where is the value of the INPUT_FILTER tag, and is the -# name of an input file. Doxygen will then use the output that the filter -# program writes to standard output. If FILTER_PATTERNS is specified, this tag -# will be ignored. -# -# Note that the filter must not add or remove lines; it is applied before the -# code is scanned, but not when the output code is generated. If lines are added -# or removed, the anchors will not be placed correctly. -# -# Note that for custom extensions or not directly supported extensions you also -# need to set EXTENSION_MAPPING for the extension otherwise the files are not -# properly processed by doxygen. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: pattern=filter -# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how -# filters are used. If the FILTER_PATTERNS tag is empty or if none of the -# patterns match the file name, INPUT_FILTER is applied. -# -# Note that for custom extensions or not directly supported extensions you also -# need to set EXTENSION_MAPPING for the extension otherwise the files are not -# properly processed by doxygen. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will also be used to filter the input files that are used for -# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). -# The default value is: NO. - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and -# it is also possible to disable source filtering for a specific pattern using -# *.ext= (so without naming a filter). -# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. - -FILTER_SOURCE_PATTERNS = - -# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page -# (index.html). This can be useful if you have a project on for instance GitHub -# and want to reuse the introduction page also for the doxygen output. - -USE_MDFILE_AS_MAINPAGE = ./README.md - -#--------------------------------------------------------------------------- -# Configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will be -# generated. Documented entities will be cross-referenced with these sources. -# -# Note: To get rid of all source code in the generated output, make sure that -# also VERBATIM_HEADERS is set to NO. -# The default value is: NO. - -SOURCE_BROWSER = YES - -# Setting the INLINE_SOURCES tag to YES will include the body of functions, -# classes and enums directly into the documentation. -# The default value is: NO. - -INLINE_SOURCES = YES - -# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any -# special comment blocks from generated source code fragments. Normal C, C++ and -# Fortran comments will always remain visible. -# The default value is: YES. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. -# The default value is: NO. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES then for each documented function -# all documented entities called/used by that function will be listed. -# The default value is: NO. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set -# to YES then the hyperlinks from functions in REFERENCES_RELATION and -# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will -# link to the documentation. -# The default value is: YES. - -REFERENCES_LINK_SOURCE = YES - -# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the -# source code will show a tooltip with additional information such as prototype, -# brief description and links to the definition and documentation. Since this -# will make the HTML file larger and loading of large files a bit slower, you -# can opt to disable this feature. -# The default value is: YES. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -SOURCE_TOOLTIPS = YES - -# If the USE_HTAGS tag is set to YES then the references to source code will -# point to the HTML generated by the htags(1) tool instead of doxygen built-in -# source browser. The htags tool is part of GNU's global source tagging system -# (see https://www.gnu.org/software/global/global.html). You will need version -# 4.8.6 or higher. -# -# To use it do the following: -# - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file -# - Make sure the INPUT points to the root of the source tree -# - Run doxygen as normal -# -# Doxygen will invoke htags (and that will in turn invoke gtags), so these -# tools must be available from the command line (i.e. in the search path). -# -# The result: instead of the source browser generated by doxygen, the links to -# source code will now point to the output of htags. -# The default value is: NO. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a -# verbatim copy of the header file for each class for which an include is -# specified. Set to NO to disable this. -# See also: Section \class. -# The default value is: YES. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all -# compounds will be generated. Enable this if the project contains a lot of -# classes, structs, unions or interfaces. -# The default value is: YES. - -ALPHABETICAL_INDEX = YES - -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all classes will -# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag -# can be used to specify a prefix (or a list of prefixes) that should be ignored -# while generating the index headers. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output -# The default value is: YES. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each -# generated HTML page (for example: .htm, .php, .asp). -# The default value is: .html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a user-defined HTML header file for -# each generated HTML page. If the tag is left blank doxygen will generate a -# standard header. -# -# To get valid HTML the header file that includes any scripts and style sheets -# that doxygen needs, which is dependent on the configuration options used (e.g. -# the setting GENERATE_TREEVIEW). It is highly recommended to start with a -# default header using -# doxygen -w html new_header.html new_footer.html new_stylesheet.css -# YourConfigFile -# and then modify the file new_header.html. See also section "Doxygen usage" -# for information on how to generate the default header that doxygen normally -# uses. -# Note: The header is subject to change so you typically have to regenerate the -# default header when upgrading to a newer version of doxygen. For a description -# of the possible markers and block names see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each -# generated HTML page. If the tag is left blank doxygen will generate a standard -# footer. See HTML_HEADER for more information on how to generate a default -# footer and what special commands can be used inside the footer. See also -# section "Doxygen usage" for information on how to generate the default footer -# that doxygen normally uses. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style -# sheet that is used by each HTML page. It can be used to fine-tune the look of -# the HTML output. If left blank doxygen will generate a default style sheet. -# See also section "Doxygen usage" for information on how to generate the style -# sheet that doxygen normally uses. -# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as -# it is more robust and this tag (HTML_STYLESHEET) will in the future become -# obsolete. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined -# cascading style sheets that are included after the standard style sheets -# created by doxygen. Using this option one can overrule certain style aspects. -# This is preferred over using HTML_STYLESHEET since it does not replace the -# standard style sheet and is therefore more robust against future updates. -# Doxygen will copy the style sheet files to the output directory. -# Note: The order of the extra style sheet files is of importance (e.g. the last -# style sheet in the list overrules the setting of the previous ones in the -# list). For an example see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that the -# files will be copied as-is; there are no commands or markers available. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen -# will adjust the colors in the style sheet and background images according to -# this color. Hue is specified as an angle on a colorwheel, see -# https://en.wikipedia.org/wiki/Hue for more information. For instance the value -# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 -# purple, and 360 is red again. -# Minimum value: 0, maximum value: 359, default value: 220. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors -# in the HTML output. For a value of 0 the output will use grayscales only. A -# value of 255 will produce the most vivid colors. -# Minimum value: 0, maximum value: 255, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the -# luminance component of the colors in the HTML output. Values below 100 -# gradually make the output lighter, whereas values above 100 make the output -# darker. The value divided by 100 is the actual gamma applied, so 80 represents -# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not -# change the gamma. -# Minimum value: 40, maximum value: 240, default value: 80. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting this -# to YES can help to show when doxygen was last run and thus if the -# documentation is up to date. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_TIMESTAMP = NO - -# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML -# documentation will contain a main index with vertical navigation menus that -# are dynamically created via Javascript. If disabled, the navigation index will -# consists of multiple levels of tabs that are statically embedded in every HTML -# page. Disable this option to support browsers that do not have Javascript, -# like the Qt help browser. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_DYNAMIC_MENUS = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_DYNAMIC_SECTIONS = NO - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries -# shown in the various tree structured indices initially; the user can expand -# and collapse entries dynamically later on. Doxygen will expand the tree to -# such a level that at most the specified number of entries are visible (unless -# a fully collapsed tree already exceeds this amount). So setting the number of -# entries 1 will produce a full collapsed tree by default. 0 is a special value -# representing an infinite number of entries and will result in a full expanded -# tree by default. -# Minimum value: 0, maximum value: 9999, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files will be -# generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: https://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See https://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_DOCSET = NO - -# This tag determines the name of the docset feed. A documentation feed provides -# an umbrella under which multiple documentation sets from a single provider -# (such as a company or product suite) can be grouped. -# The default value is: Doxygen generated docs. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# This tag specifies a string that should uniquely identify the documentation -# set bundle. This should be a reverse domain-name style string, e.g. -# com.mycompany.MyDocSet. Doxygen will append .docset to the name. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. -# The default value is: org.doxygen.Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. -# The default value is: Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three -# additional HTML index files: index.hhp, index.hhc, and index.hhk. The -# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. -# -# The HTML Help Workshop contains a compiler that can convert all HTML output -# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML -# files are now used as the Windows 98 help format, and will replace the old -# Windows help format (.hlp) on all Windows platforms in the future. Compressed -# HTML files also contain an index, a table of contents, and you can search for -# words in the documentation. The HTML workshop also contains a viewer for -# compressed HTML files. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_HTMLHELP = NO - -# The CHM_FILE tag can be used to specify the file name of the resulting .chm -# file. You can add a path in front of the file if the result should not be -# written to the html output directory. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_FILE = - -# The HHC_LOCATION tag can be used to specify the location (absolute path -# including file name) of the HTML help compiler (hhc.exe). If non-empty, -# doxygen will try to run the HTML help compiler on the generated index.hhp. -# The file has to be specified with full path. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -HHC_LOCATION = - -# The GENERATE_CHI flag controls if a separate .chi index file is generated -# (YES) or that it should be included in the master .chm file (NO). -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -GENERATE_CHI = NO - -# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) -# and project file content. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_INDEX_ENCODING = - -# The BINARY_TOC flag controls whether a binary table of contents is generated -# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it -# enables the Previous and Next buttons. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members to -# the table of contents of the HTML help documentation and to the tree view. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that -# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help -# (.qch) of the generated HTML documentation. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify -# the file name of the resulting .qch file. The path specified is relative to -# the HTML output folder. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help -# Project output. For more information please see Qt Help Project / Namespace -# (see: http://doc.qt.io/qt-4.8/qthelpproject.html#namespace). -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt -# Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://doc.qt.io/qt-4.8/qthelpproject.html#virtual-folders). -# The default value is: doc. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_VIRTUAL_FOLDER = doc - -# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom -# filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://doc.qt.io/qt-4.8/qthelpproject.html#filter-attributes). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_SECT_FILTER_ATTRS = - -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be -# generated, together with the HTML files, they form an Eclipse help plugin. To -# install this plugin and make it available under the help contents menu in -# Eclipse, the contents of the directory containing the HTML and XML files needs -# to be copied into the plugins directory of eclipse. The name of the directory -# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. -# After copying Eclipse needs to be restarted before the help appears. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the Eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have this -# name. Each documentation set should have its own identifier. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# If you want full control over the layout of the generated HTML pages it might -# be necessary to disable the index and replace it with your own. The -# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top -# of each HTML page. A value of NO enables the index and the value YES disables -# it. Since the tabs in the index contain the same information as the navigation -# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. If the tag -# value is set to YES, a side panel will be generated containing a tree-like -# index structure (just like the one that is generated for HTML Help). For this -# to work a browser that supports JavaScript, DHTML, CSS and frames is required -# (i.e. any modern browser). Windows users are probably better off using the -# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can -# further fine-tune the look of the index. As an example, the default style -# sheet generated by doxygen has an example that shows how to put an image at -# the root of the tree instead of the PROJECT_NAME. Since the tree basically has -# the same information as the tab index, you could consider setting -# DISABLE_INDEX to YES when enabling this option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_TREEVIEW = YES - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that -# doxygen will group on one line in the generated HTML documentation. -# -# Note that a value of 0 will completely suppress the enum values from appearing -# in the overview section. -# Minimum value: 0, maximum value: 20, default value: 4. -# This tag requires that the tag GENERATE_HTML is set to YES. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used -# to set the initial width (in pixels) of the frame in which the tree is shown. -# Minimum value: 0, maximum value: 1500, default value: 250. -# This tag requires that the tag GENERATE_HTML is set to YES. - -TREEVIEW_WIDTH = 250 - -# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to -# external symbols imported via tag files in a separate window. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of LaTeX formulas included as images in -# the HTML documentation. When you change the font size after a successful -# doxygen run you need to manually remove any form_*.png images from the HTML -# output directory to force them to be regenerated. -# Minimum value: 8, maximum value: 50, default value: 10. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANSPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are not -# supported properly for IE 6.0, but are supported on all modern browsers. -# -# Note that when changing this option you need to delete any form_*.png files in -# the HTML output directory before the changes have effect. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# https://www.mathjax.org) which uses client side Javascript for the rendering -# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX -# installed or if you want to formulas look prettier in the HTML output. When -# enabled you may also need to install MathJax separately and configure the path -# to it using the MATHJAX_RELPATH option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -USE_MATHJAX = NO - -# When MathJax is enabled you can set the default output format to be used for -# the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. -# Possible values are: HTML-CSS (which is slower, but has the best -# compatibility), NativeMML (i.e. MathML) and SVG. -# The default value is: HTML-CSS. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_FORMAT = HTML-CSS - -# When MathJax is enabled you need to specify the location relative to the HTML -# output directory using the MATHJAX_RELPATH option. The destination directory -# should contain the MathJax.js script. For instance, if the mathjax directory -# is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax -# Content Delivery Network so you can quickly see the result without installing -# MathJax. However, it is strongly recommended to install a local copy of -# MathJax from https://www.mathjax.org before deployment. -# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_RELPATH = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/ - -# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax -# extension names that should be enabled during MathJax rendering. For example -# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_EXTENSIONS = - -# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces -# of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an -# example see the documentation. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_CODEFILE = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box for -# the HTML output. The underlying search engine uses javascript and DHTML and -# should work on any modern browser. Note that when using HTML help -# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) -# there is already a search function so this one should typically be disabled. -# For large projects the javascript based search engine can be slow, then -# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to -# search using the keyboard; to jump to the search box use + S -# (what the is depends on the OS and browser, but it is typically -# , /