Fix latest COVs and make tcp:// rw

This commit is contained in:
pancake 2016-10-19 13:19:30 +02:00
parent 42feca7a3b
commit fbd84145f5
4 changed files with 37 additions and 11 deletions

View File

@ -1601,6 +1601,7 @@ static void do_anal_search(RCore *core, struct search_parameters *param, const c
r_cons_printf ("0x%08"PFMT64x" %d %s\n", at, ret, opstr);
break;
}
R_FREE (opstr);
if (*input && searchflags) {
char flag[64];
snprintf (flag, sizeof (flag), "%s%d_%d",

View File

@ -397,7 +397,7 @@ static int cmd_write(void *data, const char *input) {
int wseek, i, size, len = strlen (input);
RCore *core = (RCore *)data;
char *tmp, *str, *ostr;
const char *arg, *filename;
const char *arg, *filename = "";
char _fn[32];
ut64 off;
ut8 *buf;
@ -993,7 +993,9 @@ static int cmd_write(void *data, const char *input) {
const char* prefix = r_config_get (core->config, "cfg.prefixdump");
snprintf (_fn, sizeof(_fn), "%s.0x%08"PFMT64x, prefix, core->offset);
filename = _fn;
} else filename = str+1;
} else {
filename = str + 1;
}
tmp = strchr (str+1, ' ');
if (tmp) {
sz = (st64) r_num_math (core->num, tmp+1);
@ -1006,7 +1008,9 @@ static int cmd_write(void *data, const char *input) {
} else {
if (!r_file_dump (filename, core->block, core->blocksize, append)) {
sz = 0;
} else sz = core->blocksize;
} else {
sz = core->blocksize;
}
}
eprintf ("Dumped %"PFMT64d" bytes from 0x%08"PFMT64x" into %s\n",
sz, core->offset, filename);

View File

@ -12,7 +12,7 @@ static bool is_valid_project_name (const char *name) {
if (r_str_endswith (name, ".zip")) {
return false;
}
for (i=0; name[i]; i++) {
for (i = 0; name[i]; i++) {
switch (name[i]) {
case '\\': // for w32
case '.':
@ -20,12 +20,15 @@ static bool is_valid_project_name (const char *name) {
case ':':
continue;
}
if (name[i] >= 'a' && name[i] <= 'z')
if (name[i] >= 'a' && name[i] <= 'z') {
continue;
if (name[i] >= 'A' && name[i] <= 'Z')
}
if (name[i] >= 'A' && name[i] <= 'Z') {
continue;
if (name[i] >= '0' && name[i] <= '9')
}
if (name[i] >= '0' && name[i] <= '9') {
continue;
}
return false;
}
return true;
@ -180,6 +183,10 @@ static bool r_core_rop_load(RCore *core, const char *prjfile) {
int prjType = 0;
SdbNs *ns;
if (!prjfile || !*prjfile) {
return false;
}
Sdb *rop_db = sdb_ns (core->sdb, "rop", false);
Sdb *nop_db = sdb_ns (rop_db, "nop", false);
Sdb *mov_db = sdb_ns (rop_db, "mov", false);
@ -190,9 +197,6 @@ static bool r_core_rop_load(RCore *core, const char *prjfile) {
char *rcPath = r_core_project_file (core, prjfile);
char *prjDir = r_file_dirname (rcPath);
if (!prjfile || !*prjfile) {
return false;
}
if (r_str_endswith (prjfile, "/rc")) {
// XXX
eprintf ("ENDS WITH\n");
@ -206,12 +210,16 @@ static bool r_core_rop_load(RCore *core, const char *prjfile) {
if (*prjfile == '/') {
db = r_str_newf ("%s.d", prjfile);
if (!db) {
free (prjDir);
free (rcPath);
return false;
}
path = strdup (db);
} else {
db = r_str_newf ("%s/%s.d", prjDir, prjfile);
if (!db) {
free (prjDir);
free (rcPath);
return false;
}
path = r_file_abspath (db);
@ -219,6 +227,8 @@ static bool r_core_rop_load(RCore *core, const char *prjfile) {
}
if (!path) {
free (db);
free (prjDir);
free (rcPath);
return false;
}
if (rop_db) {
@ -237,6 +247,8 @@ static bool r_core_rop_load(RCore *core, const char *prjfile) {
if (!rop_db) {
free (db);
free (path);
free (prjDir);
free (rcPath);
return false;
}
sdb_ns_set (core->sdb, "rop", rop_db);
@ -260,6 +272,8 @@ static bool r_core_rop_load(RCore *core, const char *prjfile) {
free (path);
free (path_ns);
free (db);
free (prjDir);
free (rcPath);
return true;
}
@ -587,6 +601,7 @@ R_API bool r_core_project_save(RCore *core, const char *file) {
eprintf ("Warning: Cannot copy '%s' into '%s'\n", binFile, prjBinFile);
}
free (prjBinFile);
free (prjBinDir);
}
if (r_config_get_i (core->config, "prj.git")) {
char *cwd = r_sys_getdir ();

View File

@ -85,6 +85,7 @@ static ut8 *tcpme (const char *pathname, int *code, int *len) {
RSocket *sl = r_socket_new (false);
if (!r_socket_listen (sl, pathname + 1, NULL)) {
eprintf ("Cannot listen\n");
r_socket_free (sl);
return NULL;
}
RSocket *sc = r_socket_accept (sl);
@ -114,12 +115,14 @@ static ut8 *tcpme (const char *pathname, int *code, int *len) {
*code = 200;
}
r_socket_free (s);
free (host);
return res;
}
r_socket_free (s);
} else {
eprintf ("Missing port.\n");
}
free (host);
}
return NULL;
}
@ -131,7 +134,9 @@ static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
out = tcpme (pathname, &code, &rlen);
if (out && rlen > 0) {
RIOMalloc *mal = R_NEW0 (RIOMalloc);
if (!mal) return NULL;
if (!mal) {
return NULL;
}
mal->size = rlen;
mal->buf = malloc (mal->size+1);
if (!mal->buf) {
@ -142,6 +147,7 @@ static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
mal->fd = getmalfd (mal);
memcpy (mal->buf, out, mal->size);
free (out);
rw = 2;
return r_io_desc_new (&r_io_plugin_tcp,
mal->fd, pathname, rw, mode, mal);
}