* Fix lot of warning messages

This commit is contained in:
pancake 2009-03-06 00:00:41 +00:00
parent 3d76339cec
commit 03a613e7d2
33 changed files with 78 additions and 41 deletions

View file

@ -1,3 +1,2 @@
* Support short and long commands
* Support callback for null command
* Show help of commands

View file

@ -6,6 +6,7 @@ int cmd_quit(void *data, const char *input)
{
printf("quit\n");
exit(1);
return 0;
}
int cmd_echo(void *data, const char *input)
@ -14,6 +15,7 @@ int cmd_echo(void *data, const char *input)
if (arg == NULL)
arg = input;
printf("%s\n", arg+1);
return 0;
}
int main()
@ -32,4 +34,6 @@ int main()
r_cmd_call_long(&cmd, "echo hello world long");
r_cmd_call_long(&cmd, "exit");
r_cmd_call(&cmd, "quit");
return 0;
}

View file

@ -24,7 +24,7 @@ void r_config_list(struct r_config_t *cfg, const char *str, int rad)
int len = 0;
if (!strnull(str)) {
str = r_str_clean(str);
//str = r_str_clean(str);
len = strlen(str);
}

View file

@ -829,7 +829,7 @@ static int cmd_system(void *data, const char *input)
static int cmd_meta(void *data, const char *input)
{
struct r_core_t *core = (struct r_core_t *)data;
//struct r_core_t *core = (struct r_core_t *)data;
switch(input[0]) {
case '\0':
/* meta help */
@ -1097,7 +1097,7 @@ static int cmd_debug(void *data, const char *input)
switch(input[0]) {
case 's':
fprintf(stderr, "step\n");
r_debug_step(&core->dbg);
r_debug_step(&core->dbg, 1);
break;
case 'b':
fprintf(stderr, "breakpoint\n");
@ -1111,13 +1111,13 @@ static int cmd_debug(void *data, const char *input)
break;
case 'p':
if (input[1]==' ')
r_debug_select(&core->dbg, atoi(input+2));
r_debug_select(&core->dbg, core->dbg.pid, atoi(input+2));
else fprintf(stderr, "TODO: List processes..\n");
break;
case 'h':
if (input[1]==' ')
r_debug_handle_set(&core->dbg, input+2);
else r_debug_handle_list(&core->dbg);
else r_debug_handle_list(&core->dbg, "");
break;
default:
r_cons_printf("Usage: d[sbc] [arg]\n"

View file

@ -12,7 +12,6 @@ u64 r_core_file_resize(struct r_core_t *core, u64 newsize)
struct r_core_file_t *r_core_file_open(struct r_core_t *r, const char *file, int mode)
{
struct r_core_file_t *fh;
struct r_io_handle_t *iofh;
int fd;
char *p;

View file

@ -77,7 +77,7 @@ int r_core_write_at(struct r_core_t *core, u64 addr, const u8 *buf, int size)
return (ret==-1)?R_FALSE:R_TRUE;
}
int r_core_read_at(struct r_core_t *core, u64 addr, const u8 *buf, int size)
int r_core_read_at(struct r_core_t *core, u64 addr, u8 *buf, int size)
{
int ret;
r_io_lseek(&core->io, core->file->fd, addr, R_IO_SEEK_SET);

View file

@ -3,11 +3,14 @@
#include <r_debug.h>
#include <r_lib.h>
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
static int r_debug_ptrace_step(int pid)
{
u32 addr = 0; /* should be eip */
u32 data = 0;
//u32 addr = 0; /* should be eip */
//u32 data = 0;
printf("NATIVE STEP over PID=%d\n", pid);
ptrace(PTRACE_SINGLESTEP, pid, 0, 0); //addr, data);
perror("ptrace-singlestep");
@ -19,7 +22,7 @@ static int r_debug_ptrace_attach(int pid)
u32 addr;
u32 data;
int ret = ptrace(PTRACE_ATTACH, pid, addr, data);
return R_TRUE;
return (ret != -1)?R_TRUE:R_FALSE;
}
static int r_debug_ptrace_detach(int pid)
@ -45,11 +48,14 @@ static int r_debug_ptrace_wait(int pid)
return status;
}
#if 0
static int r_debug_ptrace_import(struct r_debug_handle_t *from)
{
//int pid = from->export(R_DEBUG_GET_PID);
//int maps = from->export(R_DEBUG_GET_MAPS);
return R_FALSE;
}
#endif
static struct r_debug_handle_t r_dbg_plugin_ptrace = {
.name = "ptrace",

View file

@ -10,6 +10,6 @@ test:
radiff2:
${CC} -g -I ../../include radiff2.c ${LDFLAGS} -o radiff2
clean:
myclean:
rm -f test test.o radiff2

View file

@ -60,8 +60,8 @@ int main(int argc, char **argv)
file = argv[optind];
file2 = argv[optind+1];
bufa = r_file_slurp(file, &sza);
bufb = r_file_slurp(file2, &szb);
bufa = (u8*)r_file_slurp(file, &sza);
bufb = (u8*)r_file_slurp(file2, &szb);
if (bufa == NULL || bufb == NULL) {
fprintf(stderr, "Error slurping source files\n");
return 1;

View file

@ -40,7 +40,7 @@ int main(int argc, char **argv)
printf("----\n%s\n----\n", buf);
printf("file size = %lld\n", size);
printf("CRC32: 0x%08x\n", r_hash_crc32(buf, size));
printf("CRC32: 0x%08lx\n", r_hash_crc32(buf, size));
{
struct r_hash_t ctx;

View file

@ -28,6 +28,8 @@ struct r_cmd_t {
int r_cmd_init(struct r_cmd_t *cmd);
int r_cmd_set_data(struct r_cmd_t *cmd, void *data);
int r_cmd_add(struct r_cmd_t *cmd, const char *command, const char *desc, r_cmd_callback(callback));
int r_cmd_add_long(struct r_cmd_t *cmd, const char *longcmd, const char *shortcmd, const char *desc);
int r_cmd_del(struct r_cmd_t *cmd, const char *command);
int r_cmd_call(struct r_cmd_t *cmd, const char *command);
int r_cmd_call_long(struct r_cmd_t *cmd, const char *input);
char **r_cmd_args(struct r_cmd_t *cmd, int *argc);

View file

@ -66,6 +66,7 @@ struct r_core_t *r_core_new();
int r_core_config_init(struct r_core_t *core);
int r_core_prompt(struct r_core_t *r);
int r_core_cmd(struct r_core_t *r, const char *cmd, int log);
int r_core_cmdf(void *user, const char *fmt, ...);
int r_core_cmd0(void *user, const char *cmd);
int r_core_cmd_init(struct r_core_t *core);
char *r_core_cmd_str(struct r_core_t *core, const char *cmd);
@ -73,6 +74,7 @@ int r_core_cmd_file(struct r_core_t *core, const char *file);
int r_core_seek(struct r_core_t *core, u64 addr);
int r_core_block_read(struct r_core_t *core, int next);
int r_core_block_size(struct r_core_t *core, u32 bsize);
int r_core_read_at(struct r_core_t *core, u64 addr, u8 *buf, int size);
int r_core_cmd_init(struct r_core_t *core);
int r_core_visual(struct r_core_t *core, const char *input);
int r_core_visual_cmd(struct r_core_t *core, int ch);
@ -83,4 +85,8 @@ int r_core_seek_delta(struct r_core_t *core, s64 addr);
int r_core_write_at(struct r_core_t *core, u64 addr, const u8 *buf, int size);
/* yank */
int r_core_yank(struct r_core_t *core, u64 addr, int len);
int r_core_yank_paste(struct r_core_t *core, u64 addr, int len);
#endif

View file

@ -52,7 +52,14 @@ int r_debug_handle_set(struct r_debug_t *dbg, const char *str);
int r_debug_handle_init(struct r_debug_t *dbg);
int r_debug_init(struct r_debug_t *dbg);
int r_debug_step(struct r_debug_t *dbg, int steps);
int r_debug_continue(struct r_debug_t *dbg);
int r_debug_select(struct r_debug_t *dbg, int pid, int tid);
/* handle.c */
int r_debug_handle_init(struct r_debug_t *dbg);
int r_debug_handle_set(struct r_debug_t *dbg, const char *str);
int r_debug_handle_list(struct r_debug_t *dbg, const char *str);
int r_debug_handle_add(struct r_debug_t *dbg, struct r_debug_handle_t *foo);
#if 0
Missing callbacks

View file

@ -79,6 +79,7 @@ const u8 *r_hash_state_sha512(struct r_hash_t *ctx, const u8 *input, u32 len);
/* OO */
struct r_hash_t *r_hash_state_new(int init);
void r_hash_init(struct r_hash_t *ptr, int flags);
void r_hash_state_init(struct r_hash_t *ctx, int flags);
void r_hash_state_free(struct r_hash_t *ctx);
#endif

View file

@ -84,6 +84,7 @@ int r_io_handle_open(struct r_io_t *io, int fd, struct r_io_handle_t *plugin);
int r_io_handle_close(struct r_io_t *io, int fd, struct r_io_handle_t *plugin);
int r_io_handle_generate(struct r_io_t *io);
int r_io_handle_add(struct r_io_t *io, struct r_io_handle_t *plugin);
int r_io_handle_list(struct r_io_t *io);
// TODO: _del ??
struct r_io_handle_t *r_io_handle_resolve(struct r_io_t *io, const char *filename);
struct r_io_handle_t *r_io_handle_resolve_fd(struct r_io_t *io, int fd);

View file

@ -1,6 +1,9 @@
#ifndef _INCLUDE_R_LINE_H_
#define _INCLUDE_R_LINE_H_
#include "r_types.h"
#include "r_cons.h"
#include <stdio.h>
#define R_LINE_BUFSIZE 1024

View file

@ -26,7 +26,7 @@ struct r_search_kw_t {
u32 keyword_length;
u32 binmask_length;
u32 idx; // searching purposes
u32 count;
int count;
struct list_head list;
};
@ -75,6 +75,8 @@ int r_search_set_blocksize(struct r_search_t *s, u32 bsize);
int r_search_mybinparse_update(struct r_search_t *s, u64 from, const u8 *buf, int len);
int r_search_aes_update(struct r_search_t *s, u64 from, const u8 *buf, int len);
int r_search_strings_update_char(const unsigned char *buf, int min, int max, int enc, u64 offset, const char *match);
int r_search_regexp_update(struct r_search_t *s, u64 from, const u8 *buf, int len);
int r_search_xrefs_update(struct r_search_t *s, u64 from, const u8 *buf, int len);
/* pattern search */
int r_search_pattern(struct r_search_t *s, u32 size);

View file

@ -50,13 +50,12 @@ void r_num_init(struct r_num_t *num);
#define iswhitespace(x) (x==' '||x=='\t')
#define ishexchar(x) ((x>='0'&&x<='9') || (x>='a'&&x<='f') || (x>='A'&&x<='F')) {
int r_strhash(const char *str);
/* stabilized */
int r_str_word_count(const char *string);
int r_str_word_set0(char *str);
const char *r_str_word_get0(const char *str, int idx);
int r_str_hash(const char *str);
char *r_str_clean(char *str);
int r_str_nstr(char *from, char *to, int size);
char *r_str_lchr(char *str, char chr);

View file

@ -30,7 +30,7 @@ static void perl_radare_cmd(pTHX_ CV* cv)
ST(0) = newSVpvn(str, strlen(str));
free(str);
XSRETURN(1);
str = items; /* dummy */
str = (char *)items; /* dummy unreachable code */
}
static void xs_init(pTHX)

View file

@ -1,6 +1,5 @@
/* radare - LGPL - Copyright 2007-2009 pancake<nopcode.org> */
#include "r_types.h"
#include "r_line.h"
/* dietline is a lighweight and portable library similar to GNU readline */

View file

@ -18,4 +18,6 @@ int main()
printf("%s\n", str);
r_line_hist_add(str);
}
return 0;
}

View file

@ -2,6 +2,7 @@
#include "r_cons.h"
#include "r_print.h"
#include "r_util.h"
static int flags =
R_PRINT_FLAGS_COLOR |

View file

@ -1,3 +1,4 @@
#include "r_cons.h"
#include "r_print.h"
int main()
@ -5,7 +6,7 @@ int main()
u8 *buf = (u8*)main;
r_cons_init();
r_print_hexdump(main, buf, 128, 1, 78, 1);
r_print_hexdump((u64)(u32)(main), buf, 128, 1, 78, 1);
r_cons_flush();
return 0;

View file

@ -61,7 +61,10 @@ all: ${BIN}
${BIN}: ${OBJ}
${CC} ${LDFLAGS} ${OBJ} -o ${BIN} ${LIBS}
clean:
#Dummy myclean rule that can be overriden by the t/ Makefile
myclean:
clean: myclean
-rm -f ${OBJ} ${BIN}
.PHONY: all clean ${BIN}

View file

@ -61,7 +61,7 @@ int do_byte_pat(int patlen)
static fnditem* root;
u64 bproc = 0;
u64 rb;
const char *str;
//const char *str;
int nr,i, moar;
int pcnt, cnt=0, k=0;
u64 intaddr;
@ -160,7 +160,7 @@ int r_search_pattern_update(int patlen)
static fnditem* root;
u64 bproc = 0;
u64 rb;
const char *str;
//const char *str;
int nr,i, moar;
int pcnt, cnt=0, k=0;
u64 intaddr;

View file

@ -8,7 +8,7 @@ int r_search_regexp_update(struct r_search_t *s, u64 from, const u8 *buf, int le
struct list_head *pos;
char *buffer = malloc(len+1);
char *skipz, *end;
int i, count = 0;
int count = 0;
memcpy(buffer, buf, len);
buffer[len]='\0';
@ -28,7 +28,7 @@ int r_search_regexp_update(struct r_search_t *s, u64 from, const u8 *buf, int le
return -1;
}
foo:
ret = regexec(&compiled, buffer+delta, 1, &matches, 0);
ret = regexec(&compiled, buffer+delta, 1, matches, 0);
if (ret) {
return 0;
} else
@ -36,12 +36,12 @@ int r_search_regexp_update(struct r_search_t *s, u64 from, const u8 *buf, int le
if (s->callback)
s->callback(kw, s->user, (u64)from+matches[0].rm_so+delta);
else printf("hit%d_%d 0x%08llx ; %s\n",
count, kw->count, (u64)from+matches[0].rm_so,
count, kw->count, (u64)(from+matches[0].rm_so),
buf+matches[0].rm_so+delta);
delta += matches[0].rm_so+1;
kw->count++;
count++;
} while(!regexec(&compiled, buffer+delta, 1, &matches, 0));
} while(!regexec(&compiled, buffer+delta, 1, matches, 0));
if (delta == 0)
return 0;

View file

@ -13,6 +13,6 @@ test-regexp:
test-str:
${CC} -g -I ../../include test-str.c ${LDFLAGS} -o test-str
clean:
myclean:
rm -f test test.o test-str test-str.o test-regexp

View file

@ -16,7 +16,7 @@ int main(int argc, char **argv)
rs = r_search_new(R_SEARCH_REGEXP);
r_search_set_callback(rs, &hit, buffer);
r_search_kw_add(rs, "E.F", "i"); /* search for /E.F/i */
r_search_initialize(rs);
r_search_begin(rs);
printf("Searching strings in '%s'\n", buffer);
r_search_update_i(rs, 0LL, buffer, strlen(buffer));
rs = r_search_free(rs);

View file

@ -15,7 +15,7 @@ int main(int argc, char **argv)
rs = r_search_new(R_SEARCH_STRING);
r_search_set_callback(rs, &hit, buffer);
r_search_initialize(rs);
r_search_begin(rs);
printf("Searching strings in '%s'\n", buffer);
r_search_update_i(rs, 0LL, buffer, strlen(buffer));
rs = r_search_free(rs);

View file

@ -5,8 +5,8 @@
int r_search_xrefs_update(struct r_search_t *s, u64 from, const u8 *buf, int len)
{
u8 code[1024];
u8 mask[1024];
// u8 code[1024];
// u8 mask[1024];
int count = 0;
//get_delta_for(
//if (r_mem_cmp_mask(buf, code, mask, 4)) {

View file

@ -7,7 +7,7 @@
#if 0
buf |__________________________________|
bufptr[] ^ ^ ^ ^ ^
bufidx >---------------------------'
bufidx >---------------------------/
#endif
/* 256 chunks with 30 KB */
@ -31,7 +31,7 @@ int r_alloca_init()
return R_TRUE;
}
char *r_alloca_bytes(int len)
u8 *r_alloca_bytes(int len)
{
u8 *next = bufnext;
u8 *tnext = bufnext + len;
@ -44,7 +44,7 @@ char *r_alloca_bytes(int len)
char *r_alloca_str(const char *str)
{
int len;
char *p;
u8 *p;
if (str == NULL) {
len = 1;
p = r_alloca_bytes(1);
@ -55,7 +55,7 @@ char *r_alloca_str(const char *str)
if (p != NULL)
memcpy(p, str, len);
}
return p;
return (char *)p;
}
/* free last allocated buffer */

View file

@ -31,7 +31,7 @@ char *r_file_path(const char *bin)
ptr = strchr(str, ':');
if (ptr) {
ptr[0]='\0';
snprintf(file, "%s/%s", str, bin);
snprintf(file, 1023, "%s/%s", str, bin);
if (r_file_exist(file)) {
free(path);
return strdup(file);
@ -81,7 +81,7 @@ char *r_file_slurp_random_line(const char *file)
{
int i, lines = 0;
struct timeval tv;
u32 sz;
int sz;
char *ptr, *str = r_file_slurp(file, &sz);
if (str) {
gettimeofday(&tv,NULL);

View file

@ -116,9 +116,9 @@ int r_var_add_access(struct r_var_t *var, u64 addr, int delta, int type, int set
u64 from = 0LL, to = 0LL;
struct list_head *pos;
struct r_var_item_t *v;
int reloop = 0;
//int reloop = 0;
_reloop:
//_reloop:
list_for_each(pos, &var->vars) {
v = (struct r_var_item_t*)list_entry(pos, struct r_var_item_t, list);
if (addr >= v->addr) {
@ -137,6 +137,7 @@ int r_var_add_access(struct r_var_t *var, u64 addr, int delta, int type, int set
/* detect function in CF list */
from = to = 0LL;
// XXX USE RMETA HERE!!
#if 0
if ( data_get_fun_for(addr, &from, &to) ) {
char varname[32];
if (delta < 0) {
@ -154,6 +155,7 @@ int r_var_add_access(struct r_var_t *var, u64 addr, int delta, int type, int set
goto _reloop;
return r_var_add_access(var, addr, delta, type, set);
} else fprintf(stderr, "Cannot find bounding function at 0x%08llx\n", addr);
#endif
return 0;
}