Balance spacings in braces ##indent

This commit is contained in:
pancake 2022-10-13 21:21:34 +02:00 committed by GitHub
parent bf4f6a6504
commit a06ade1796
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
93 changed files with 20226 additions and 20251 deletions

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2013 - 2014 - condret@runas-racer.com */
/* radare - LGPL - Copyright 2013-2022 - condret */
#define GB_8BIT 1
#define GB_16BIT 2
@ -6,16 +6,17 @@
#define ARG_16 8
#define GB_IO 16 // Most io (Joypad, Sound, Screen ...)
typedef struct {
const char *name;
const int type;
} gb_opcode;
static const char *cb_ops[]={ "rlc","rrc","rl","rr","sla","sra","swap","srl",
static const char *cb_ops[] = {
"rlc", "rrc", "rl", "rr", "sla", "sra", "swap", "srl",
"bit 0,", "bit 1,", "bit 2,", "bit 3,", "bit 4,", "bit 5,", "bit 6,", "bit 7,",
"res 0,", "res 1,", "res 2,", "res 3,", "res 4,", "res 5,", "res 6,", "res 7,",
"set 0,","set 1,","set 2,","set 3,","set 4,","set 5,","set 6,","set 7,"};
"set 0,", "set 1,", "set 2,", "set 3,", "set 4,", "set 5,", "set 6,", "set 7,"
};
static const char *cb_regs[]= { "b", "c", "d", "e", "h", "l", "[hl]", "a" };
@ -36,7 +37,6 @@ static gb_opcode gb_op[] = {
{ "dec c", GB_8BIT },
{ "ld c, 0x%02x", GB_8BIT + ARG_8 },
{ "rrca", GB_8BIT },
{ "stop", GB_8BIT }, //0x10
{ "ld de, 0x%04x" ,GB_8BIT+ARG_16},
{ "ld [de], a" ,GB_8BIT },

0
libr/anal/arch/kvx/opc.sed Executable file → Normal file
View File

View File

@ -1,14 +1,9 @@
/* radare - LGPL - Copyright 2012 - pancake<nopcode.org>
2022 - condret
/* radare - LGPL - Copyright 2012 - pancake<nopcode.org> 2022 - condret
this file was based on anal_i8080.c */
#include <string.h>
#include <r_types.h>
#include <r_util.h>
#include <r_asm.h>
#include <r_anal.h>
#include <r_reg.h>
#include "gb/gbdis.c"
#include "gb/gbasm.c"
#include "gb/gb_makros.h"
@ -16,11 +11,11 @@
#include "gb/gb_makros.h"
#include "gb/gb.h"
static const char *regs_1[] = { "Z", "N", "H", "C"};
static const char *regs_8[] = { "b", "c", "d", "e", "h", "l", "a", "a"}; //deprecate this and rename regs_x
static const char *regs_x[] = { "b", "c", "d", "e", "h", "l", "hl", "a"};
static const char *regs_16[] = { "bc", "de", "hl", "sp"};
static const char *regs_16_alt[] = { "bc", "de", "hl", "af" };
static const char * const regs_1[] = { "Z", "N", "H", "C" };
static const char * const regs_8[] = { "b", "c", "d", "e", "h", "l", "a", "a" }; //deprecate this and rename regs_x
static const char * const regs_x[] = { "b", "c", "d", "e", "h", "l", "hl", "a" };
static const char * const regs_16[] = { "bc", "de", "hl", "sp" };
static const char * const regs_16_alt[] = { "bc", "de", "hl", "af" };
static ut8 gb_op_calljump(RAnal *a, RAnalOp *op, const ut8 *data, ut64 addr) {
if (GB_IS_RAM_DST (data[1],data[2])) {

View File

@ -87,9 +87,11 @@ typedef struct Opcode_t {
static int get_mem_option(char *token) {
// values 4, 8, 12, are unused. XXX to adjust
const char *options[] = {"sy", "st", "ld", "xxx", "ish", "ishst",
const char *options[] = {
"sy", "st", "ld", "xxx", "ish", "ishst",
"ishld", "xxx", "nsh", "nshst", "nshld",
"xxx", "osh", "oshst", "oshld", NULL};
"xxx", "osh", "oshst", "oshld", NULL
};
int i = 0;
while (options[i]) {
if (!r_str_casecmp (token, options[i])) {

View File

@ -3874,8 +3874,7 @@ print_insn_coprocessor (bfd_vma pc,
case '3': /* List */
func (stream, "{");
regno = (given >> 12) & 0x0000000f;
if (single)
{
if (single) {
regno <<= 1;
regno += (given >> 22) & 1;
} else {

View File

@ -1,5 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
/* radare - LGPL - Copyright 2019-2022 - mrmacete, pancake */
#include <r_util.h>
#include <r_util/r_xml.h>
#include <r_list.h>
@ -346,7 +346,6 @@ static void r_cf_value_dict_add(RCFValueDict *dict, RCFKeyValue *key_value) {
if (!dict || !dict->pairs) {
return;
}
r_list_push (dict->pairs, key_value);
}
@ -368,28 +367,21 @@ static void r_cf_value_dict_print(RCFValueDict *dict) {
static RCFValueArray *r_cf_value_array_new(void) {
RCFValueArray *array = R_NEW0 (RCFValueArray);
if (!array) {
return NULL;
}
if (array) {
array->type = R_CF_ARRAY;
array->values = r_list_newf ((RListFree)&r_cf_value_free);
}
return array;
}
static void r_cf_value_array_free(RCFValueArray *array) {
if (!array) {
return;
}
if (array) {
if (array->values) {
r_list_free (array->values);
array->values = NULL;
}
array->type = R_CF_INVALID;
R_FREE (array);
free (array);
}
}
static void r_cf_value_array_add(RCFValueArray *array, RCFValue *value) {

View File

@ -543,8 +543,10 @@ R_API void r_core_anal_autoname_all_golang_fcns(RCore *core) {
r_name_filter ((char *)func_name, 0);
//r_cons_printf ("[x] Found symbol %s at 0x%x\n", func_name, func_addr);
char *flagname = r_str_newf ("sym.go.%s", func_name);
if (flagname) {
r_flag_set (core->flags, flagname, func_addr, 1);
free (flagname);
}
offset += 2 * ptr_size;
num_syms++;
}
@ -599,12 +601,13 @@ static bool r_anal_try_get_fcn(RCore *core, RAnalRef *ref, int fcndepth, int ref
if (map->perm & R_PERM_X) {
ut8 buf[64];
r_io_read_at (core->io, ref->addr, buf, sizeof (buf));
bool looksLikeAFunction = r_anal_check_fcn (core->anal, buf, sizeof (buf), ref->addr, r_io_map_begin (map),
r_io_map_end (map));
bool looksLikeAFunction = r_anal_check_fcn (core->anal, buf, sizeof (buf), ref->addr, r_io_map_begin (map), r_io_map_end (map));
if (looksLikeAFunction) {
if (core->anal->limit) {
if (ref->addr < core->anal->limit->from ||
ref->addr > core->anal->limit->to) {
if (ref->addr < core->anal->limit->from) {
return 1;
}
if (ref->addr > core->anal->limit->to) {
return 1;
}
}

View File

@ -2,7 +2,7 @@
#include <r_core.h>
static const char *help_msg_at[] = {
static RCoreHelpMessage help_msg_at = {
"Usage: [.][#]<cmd>[*] [`cmd`] [@ addr] [~grep] [|syscmd] [>[>]file]", "", "",
"0", "", "alias for 's 0'",
"0x", "addr", "alias for 's 0x..'",
@ -58,7 +58,7 @@ static const char *help_msg_at[] = {
NULL
};
static const char *help_msg_at_at[] = {
static RCoreHelpMessage help_msg_at_at = {
"@@", "", " # foreach iterator command:",
"x", " @@ sym.*", "run 'x' over all flags matching 'sym.' in current flagspace",
"x", " @@.file", "run 'x' over the offsets specified in the file (one offset per line)",
@ -79,7 +79,7 @@ static const char *help_msg_at_at[] = {
NULL
};
static const char *help_msg_at_at_at[] = {
static RCoreHelpMessage help_msg_at_at_at = {
"@@@", "", " # foreach offset+size iterator command:",
"x", " @@@=", "[addr] [size] ([addr] [size] ...)",
"x", " @@@C:cmd", "comments matching",
@ -217,7 +217,7 @@ static const char *help_msg_root[] = {
NULL
};
static const char *help_msg_question_i[] = {
static RCoreHelpMessage help_msg_question_i = {
"Usage: ?e[=bdgnpst] arg", "print/echo things", "",
"?i", " ([prompt])", "inquery the user and save that text into the yank clipboard (y)",
"?ie", " [msg]", "same as ?i, but prints the output, useful for oneliners",
@ -229,7 +229,7 @@ static const char *help_msg_question_i[] = {
"?ip", " ([path])", "interactive hud mode to find files in given path",
NULL
};
static const char *help_msg_question_e[] = {
static RCoreHelpMessage help_msg_question_e = {
"Usage: ?e[=bdgnpst] arg", "print/echo things", "",
"?e", "", "echo message with newline",
"?e=", " 32", "progress bar at 32 percentage",
@ -245,7 +245,7 @@ static const char *help_msg_question_e[] = {
NULL
};
static const char *help_msg_question[] = {
static RCoreHelpMessage help_msg_question = {
"Usage: ?[?[?]] expression", "", "",
"?!", " [cmd]", "run cmd if $? == 0",
"?", " eip-0x804800", "show all representation result for this math expr",

View File

@ -1,11 +1,10 @@
/* radare - Apache - Copyright 2014-2020 - dso, pancake */
/* radare - Apache - Copyright 2014-2022 - dso, pancake */
#include <r_types.h>
#include <r_lib.h>
#include <r_cmd.h>
#include <r_core.h>
#include <r_cons.h>
#include <string.h>
#include <r_anal.h>
#include "../../../shlr/java/ops.h"
@ -16,7 +15,6 @@
#undef IFDBG
#define IFDBG if (DO_THE_DBG)
typedef struct found_idx_t {
ut16 idx;
ut64 addr;

View File

@ -1326,7 +1326,7 @@ beach:
#else
R_API int r_core_rtr_cmds(RCore *core, const char *port) {
unsigned char buf[4097];
ut8 buf[4097];
RSocket *ch = NULL;
int i, ret;
char *str;

0
libr/syscall/d/par.sh Executable file → Normal file
View File

View File

@ -5,9 +5,9 @@
extern "C" {
#endif
struct r_oid_list_t {
const char* oid;
const char* name;
const struct r_oid_list_t {
const char* const oid;
const char* const name;
} X509OIDList [] = {
{ "0.2.262.1.10", "Telesec" },
{ "0.2.262.1.10.0", "extension" },

View File

@ -1,15 +1,16 @@
/* radare - LGPL - Copyright 2007-2020 - pancake, ret2libc */
#include <r_core.h>
#include <r_util/r_graph_drawable.h>
R_API void r_graph_free_node_info(void *ptr) {
if (!ptr) {
return;
}
if (ptr) {
RGraphNodeInfo *info = ptr;
free (info->body);
free (info->title);
free (info);
}
}
R_API RGraphNodeInfo *r_graph_create_node_info(const char *title, const char *body, ut64 offset) {
RGraphNodeInfo *data = R_NEW0 (RGraphNodeInfo);

View File

@ -833,7 +833,13 @@ R_API int r_sys_cmdbg(const char *str) {
return pid;
}
int ret = r_sandbox_system (str, 0);
eprintf ("{exit: %d, pid: %d, cmd: \"%s\"}", ret, pid, str);
PJ *pj = pj_new ();
pj_kn (pj, "exit", ret);
pj_kn (pj, "pid", pid);
pj_ks (pj, "cmd", str);
char *s = pj_drain (pj);
eprintf ("%s\n", s);
free (s);
exit (0);
return -1;
#else

View File

@ -1,6 +1,7 @@
/* Apache 2.0 - Copyright 2007-2022 - pancake and dso
class.c rewrite: Adam Pridgen <dso@rice.edu || adam.pridgen@thecoverofnight.com>
*/
/* Apache 2.0 - Copyright 2007-2022 - pancake and dso */
/* class.c rewrite: Adam Pridgen <dso@rice.edu || adam.pridgen@thecoverofnight.com> */
#define R_LOG_ORIGIN "java.class"
#include <r_bin.h>
#include <math.h>
#include "class.h"
@ -15,12 +16,16 @@
#define MAX_CPITEMS 16
static const ut16 R_BIN_JAVA_ELEMENT_VALUE_METAS_SZ = 14;
static const ut32 RBIN_JAVA_ATTRS_METAS_SZ = 20;
static R_TH_LOCAL bool R_BIN_JAVA_NULL_TYPE_INITTED = false;
static R_TH_LOCAL RBinJavaObj *R_BIN_JAVA_GLOBAL_BIN = NULL;
R_API char *U(r_bin_java_unmangle_method)(const char *flags, const char *name, const char *params, const char *r_value);
R_API int r_bin_java_is_fm_type_private(RBinJavaField *fm_type);
R_API int r_bin_java_is_fm_type_protected(RBinJavaField *fm_type);
R_API ut32 U(r_bin_java_swap_uint)(ut32 x);
// R_API const char * r_bin_java_get_this_class_name(RBinJavaObj *bin);
R_API void U(add_cp_objs_to_sdb)(RBinJavaObj * bin);
R_API void U(add_field_infos_to_sdb)(RBinJavaObj * bin);
R_API void U(add_method_infos_to_sdb)(RBinJavaObj * bin);
@ -381,9 +386,6 @@ static RBinJavaRefMetas R_BIN_JAVA_REF_METAS[] = {
{ "NewInvokeSpecial", R_BIN_JAVA_REF_NEWINVOKESPECIAL },
{ "InvokeInterface", R_BIN_JAVA_REF_INVOKEINTERFACE }
};
static const ut16 R_BIN_JAVA_ELEMENT_VALUE_METAS_SZ = 14;
static R_TH_LOCAL bool R_BIN_JAVA_NULL_TYPE_INITTED = false;
static R_TH_LOCAL RBinJavaObj *R_BIN_JAVA_GLOBAL_BIN = NULL;
static RBinJavaElementValueMetas R_BIN_JAVA_ELEMENT_VALUE_METAS[] = {
{ "Byte", R_BIN_JAVA_EV_TAG_BYTE, NULL },
@ -492,8 +494,6 @@ static RBinJavaAttrInfoObjectAllocs RBIN_JAVA_ATTRS_ALLOCS[] = {
{ r_bin_java_synthetic_attr_new, r_bin_java_synthetic_attr_free, r_bin_java_print_synthetic_attr_summary, r_bin_java_synthetic_attr_calc_size },
{ r_bin_java_unknown_attr_new, r_bin_java_unknown_attr_free, r_bin_java_print_unknown_attr_summary, r_bin_java_unknown_attr_calc_size }
};
// R_API ut32 RBIN_JAVA_ATTRS_METAS_SZ = 21;
static ut32 RBIN_JAVA_ATTRS_METAS_SZ = 20;
static RBinJavaAttrMetas RBIN_JAVA_ATTRS_METAS[] = {
{ "AnnotationDefault", R_BIN_JAVA_ATTR_TYPE_ANNOTATION_DEFAULT_ATTR, &RBIN_JAVA_ATTRS_ALLOCS[0] },
{ "BootstrapMethods", R_BIN_JAVA_ATTR_TYPE_BOOTSTRAP_METHODS_ATTR, &RBIN_JAVA_ATTRS_ALLOCS[1] },
@ -1644,80 +1644,59 @@ R_API RBinJavaInterfaceInfo *r_bin_java_read_next_interface_item(RBinJavaObj *bi
}
return ifobj;
}
// R_API void addrow (RBinJavaObj *bin, int addr, int line) {
// int n = bin->lines.count++;
//// XXX. possible memleak
// bin->lines.addr = realloc (bin->lines.addr, sizeof (int)*n+1);
// bin->lines.addr[n] = addr;
// bin->lines.line = realloc (bin->lines.line, sizeof (int)*n+1);
// bin->lines.line[n] = line;
// }
// R_API struct r_bin_java_cp_item_t* r_bin_java_get_item_from_cp_CP(RBinJavaObj *bin, int i) {
// return (i<0||i>bin->cf.cp_count)? &cp_null_item: &bin->cp_items[i];
// }
R_API char *r_bin_java_get_utf8_from_bin_cp_list(RBinJavaObj *bin, ut64 idx) {
r_return_val_if_fail (bin, NULL);
/*
Search through the Constant Pool list for the given CP Index.
If the idx not found by directly going to the list index,
the list will be walked and then the IDX will be checked.
rvalue: new char* for caller to free.
*/
if (bin == NULL) {
return NULL;
}
return r_bin_java_get_utf8_from_cp_item_list (bin->cp_list, idx);
}
R_API ut32 r_bin_java_get_utf8_len_from_bin_cp_list(RBinJavaObj *bin, ut64 idx) {
r_return_val_if_fail (bin, 0);
/*
Search through the Constant Pool list for the given CP Index.
If the idx not found by directly going to the list index,
the list will be walked and then the IDX will be checked.
rvalue: new char* for caller to free.
*/
if (bin == NULL) {
return 0;
}
return r_bin_java_get_utf8_len_from_cp_item_list (bin->cp_list, idx);
}
R_API char *r_bin_java_get_name_from_bin_cp_list(RBinJavaObj *bin, ut64 idx) {
r_return_val_if_fail (bin, NULL);
/*
Search through the Constant Pool list for the given CP Index.
If the idx not found by directly going to the list index,
the list will be walked and then the IDX will be checked.
rvalue: new char* for caller to free.
*/
if (bin == NULL) {
return NULL;
}
return r_bin_java_get_name_from_cp_item_list (bin->cp_list, idx);
}
R_API char *r_bin_java_get_desc_from_bin_cp_list(RBinJavaObj *bin, ut64 idx) {
r_return_val_if_fail (bin, NULL);
/*
Search through the Constant Pool list for the given CP Index.
If the idx not found by directly going to the list index,
the list will be walked and then the IDX will be checked.
rvalue: new char* for caller to free.
*/
if (bin == NULL) {
return NULL;
}
return r_bin_java_get_desc_from_cp_item_list (bin->cp_list, idx);
}
R_API RBinJavaCPTypeObj *r_bin_java_get_item_from_bin_cp_list(RBinJavaObj *bin, ut64 idx) {
r_return_val_if_fail (bin, NULL);
/*
Search through the Constant Pool list for the given CP Index.
If the idx not found by directly going to the list index,
the list will be walked and then the IDX will be checked.
rvalue: RBinJavaObj* (user does NOT free).
*/
if (bin == NULL) {
return NULL;
}
if (idx > bin->cp_count || idx == 0) {
return r_bin_java_get_java_null_cp ();
}
@ -2013,16 +1992,13 @@ R_API RBinJavaAttrInfo *r_bin_java_read_next_attr(RBinJavaObj *bin, const ut64 o
const ut8 *a_buf = offset + buf;
ut8 attr_idx_len = 6;
if (offset + 6 > buf_len) {
eprintf ("[X] r_bin_java: Error unable to parse remainder of classfile in Attribute offset "
"(0x%"PFMT64x ") > len of remaining bytes (0x%"PFMT64x ").\n", offset, buf_len);
R_LOG_ERROR ("unable to parse Attribute offset (0x%"PFMT64x ") > len (0x%"PFMT64x ")", offset, buf_len);
return NULL;
}
// ut16 attr_idx, ut32 length of attr.
ut32 sz = R_BIN_JAVA_UINT (a_buf, 2) + attr_idx_len; // r_bin_java_read_int (bin, buf_offset+2) + attr_idx_len;
if (sz + offset > buf_len) {
eprintf ("[X] r_bin_java: Error unable to parse remainder of classfile in Attribute len "
"(0x%x) + offset (0x%"PFMT64x ") exceeds length of buffer (0x%"PFMT64x ").\n",
sz, offset, buf_len);
R_LOG_ERROR ("Unable to parse class Attribute len (0x%x) + offset (0x%"PFMT64x ") exceeds length of buffer (0x%"PFMT64x ")", sz, offset, buf_len);
return NULL;
}
// when reading the attr bytes, need to also

View File

@ -3,6 +3,9 @@
cd "$(dirname $0)"/..
# (git grep -e '_[a-z][a-z](' libr | grep -v '{'| grep c:) && exit 1
# TODO : also check for '{0x'
(git grep '\t{"' libr | grep -v strcmp | grep -v format | grep -v '{",' | grep -v esil | grep c:) && exit 1
(git grep '"},' libr | grep -v strcmp | grep -v format | grep -v '"},' | grep -v '"}{' | grep -v esil | grep -v anal/p | grep c:) && exit 1
(git grep '^\ \ \ ' libr | grep -v '/arch/' | grep -v dotnet | grep -v mangl | grep c:) && exit 1
(git grep 'TODO' libr | grep R_LOG_INFO) && exit 1
( git grep r_config_set libr binr | grep -e '"fal' -e '"tru') && exit 1