mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-13 16:18:33 +00:00
Use strncmp instead of memcmp to check the io uri
This commit is contained in:
parent
04826d8064
commit
6f2baaa202
@ -137,7 +137,7 @@ static ut64 __lseek(RIO *io, RIODesc *fd, ut64 offset, int whence) {
|
||||
}
|
||||
|
||||
static int __plugin_open(RIO *io, const char *pathname, ut8 many) {
|
||||
return (!memcmp (pathname, "bfdbg://", 8));
|
||||
return (!strncmp (pathname, "bfdbg://", 8));
|
||||
}
|
||||
|
||||
static inline int getmalfd (RIOBfdbg *mal) {
|
||||
|
@ -261,7 +261,7 @@ static int fork_and_ptraceme(int bits, const char *cmd) {
|
||||
#endif
|
||||
|
||||
static int __plugin_open(RIO *io, const char *file, ut8 many) {
|
||||
if (!memcmp (file, "dbg://", 6) && file[6])
|
||||
if (!strncmp (file, "dbg://", 6) && file[6])
|
||||
return R_TRUE;
|
||||
return R_FALSE;
|
||||
}
|
||||
|
@ -61,8 +61,8 @@ static ut64 ewf__lseek(RIO *io, RIODesc *fd, ut64 offset, int whence) {
|
||||
}
|
||||
|
||||
static int ewf__plugin_open(RIO *io, const char *pathname, ut8 many) {
|
||||
if ((!memcmp (pathname, "ewf://", 6))
|
||||
|| (!memcmp (pathname, "els://", 6)))
|
||||
if ((!strncmp (pathname, "ewf://", 6))
|
||||
|| (!strncmp (pathname, "els://", 6)))
|
||||
return R_TRUE;
|
||||
return R_FALSE;
|
||||
}
|
||||
@ -86,7 +86,7 @@ static RIODesc *ewf__open(RIO *io, const char *pathname, int rw, int mode) {
|
||||
uint8_t format;
|
||||
int i;
|
||||
|
||||
if (!memcmp (pathname, "els://", 6)) {
|
||||
if (!strncmp (pathname, "els://", 6)) {
|
||||
FILE *fd = r_sandbox_fopen (pathname+6, "r");
|
||||
ut64 len;
|
||||
char *buf;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2010-2013 pancake */
|
||||
/* radare - LGPL - Copyright 2010-2014 pancake */
|
||||
|
||||
#include <r_io.h>
|
||||
#include <r_lib.h>
|
||||
@ -20,7 +20,7 @@ typedef struct {
|
||||
#define NUM_REGS 28
|
||||
|
||||
static int __plugin_open(RIO *io, const char *file, ut8 many) {
|
||||
return (!memcmp (file, "gdb://", 6));
|
||||
return (!strncmp (file, "gdb://", 6));
|
||||
}
|
||||
|
||||
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
|
||||
|
@ -69,7 +69,7 @@ static int haret__close(RIODesc *fd) {
|
||||
}
|
||||
|
||||
static int haret__plugin_open(struct r_io_t *io, const char *pathname, ut8 many) {
|
||||
return (!memcmp (pathname, "haret://", 8));
|
||||
return (!strncmp (pathname, "haret://", 8));
|
||||
}
|
||||
|
||||
static RIODesc *haret__open(struct r_io_t *io, const char *pathname, int rw, int mode) {
|
||||
|
@ -60,7 +60,7 @@ static ut64 __lseek(struct r_io_t *io, RIODesc *fd, ut64 offset, int whence) {
|
||||
}
|
||||
|
||||
static int __plugin_open(struct r_io_t *io, const char *pathname, ut8 many) {
|
||||
return (!memcmp (pathname, "http://", 7));
|
||||
return (!strncmp (pathname, "http://", 7));
|
||||
}
|
||||
|
||||
static inline int getmalfd (RIOMalloc *mal) {
|
||||
|
@ -95,7 +95,7 @@ static ut64 __lseek(struct r_io_t *io, RIODesc *fd, ut64 offset, int whence) {
|
||||
}
|
||||
|
||||
static int __plugin_open(RIO *io, const char *pathname, ut8 many) {
|
||||
return (!memcmp (pathname, "ihex://", 7));
|
||||
return (!strncmp (pathname, "ihex://", 7));
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -131,7 +131,8 @@ static int __write(RIO *io, RIODesc *fd, const ut8 *buf, int len) {
|
||||
}
|
||||
|
||||
static int __plugin_open(RIO *io, const char *file, ut8 many) {
|
||||
return (!memcmp (file, "attach://", 9) || !memcmp (file, "mach://", 7));
|
||||
return (!strncmp (file, "attach://", 9) \
|
||||
|| !strncmp (file, "mach://", 7));
|
||||
}
|
||||
|
||||
//static task_t inferior_task = 0;
|
||||
|
@ -80,8 +80,8 @@ static ut64 __lseek(RIO* io, RIODesc *fd, ut64 offset, int whence) {
|
||||
|
||||
static int __plugin_open(struct r_io_t *io, const char *pathname, ut8 many) {
|
||||
return (
|
||||
(!memcmp (pathname, "malloc://", 9)) ||
|
||||
(!memcmp (pathname, "hex://", 6))
|
||||
(!strncmp (pathname, "malloc://", 9)) ||
|
||||
(!strncmp (pathname, "hex://", 6))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
/* radare - LGPL - Copyright 2013 - pancake */
|
||||
/* radare - LGPL - Copyright 2013-2014 - pancake */
|
||||
|
||||
#include <r_userconf.h>
|
||||
#include <r_io.h>
|
||||
#include <r_lib.h>
|
||||
|
||||
static int __plugin_open(RIO *io, const char *file, ut8 many) {
|
||||
return (!memcmp (file, "mmap://", 7));
|
||||
return (!strncmp (file, "mmap://", 7));
|
||||
}
|
||||
|
||||
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
|
||||
|
@ -51,7 +51,7 @@ static int __write(struct r_io_t *io, RIODesc *fd, const ut8 *buf, int len) {
|
||||
}
|
||||
|
||||
static int __plugin_open(struct r_io_t *io, const char *file, ut8 many) {
|
||||
return (!memcmp (file, "procpid://", 10));
|
||||
return (!strncmp (file, "procpid://", 10));
|
||||
}
|
||||
|
||||
static RIODesc *__open(struct r_io_t *io, const char *file, int rw, int mode) {
|
||||
|
@ -116,10 +116,10 @@ static void close_pidmem(RIOPtrace *iop) {
|
||||
}
|
||||
}
|
||||
|
||||
static int __plugin_open(struct r_io_t *io, const char *file, ut8 many) {
|
||||
if (!memcmp (file, "ptrace://", 9))
|
||||
static int __plugin_open(RIO *io, const char *file, ut8 many) {
|
||||
if (!strncmp (file, "ptrace://", 9))
|
||||
return R_TRUE;
|
||||
if (!memcmp (file, "attach://", 9))
|
||||
if (!strncmp (file, "attach://", 9))
|
||||
return R_TRUE;
|
||||
return R_FALSE;
|
||||
}
|
||||
|
@ -118,7 +118,8 @@ static ut64 rap__lseek(struct r_io_t *io, RIODesc *fd, ut64 offset, int whence)
|
||||
}
|
||||
|
||||
static int rap__plugin_open(struct r_io_t *io, const char *pathname, ut8 many) {
|
||||
return (!memcmp (pathname,"rap://",6))||(!memcmp (pathname,"raps://",7));
|
||||
return (!strncmp (pathname,"rap://",6)) \
|
||||
|| (!strncmp (pathname,"raps://",7));
|
||||
}
|
||||
|
||||
static RIODesc *rap__open(struct r_io_t *io, const char *pathname, int rw, int mode) {
|
||||
@ -131,7 +132,7 @@ static RIODesc *rap__open(struct r_io_t *io, const char *pathname, int rw, int m
|
||||
|
||||
if (!rap__plugin_open (io, pathname,0))
|
||||
return NULL;
|
||||
is_ssl = (!memcmp (pathname, "raps://", 7));
|
||||
is_ssl = (!strncmp (pathname, "raps://", 7));
|
||||
ptr = pathname + (is_ssl? 7: 6);
|
||||
if (!(port = strchr (ptr, ':'))) {
|
||||
eprintf ("rap: wrong uri\n");
|
||||
|
@ -48,7 +48,7 @@ static int self_in_section(ut64 addr, int *left, int *perm) {
|
||||
}
|
||||
|
||||
static int __plugin_open(RIO *io, const char *file, ut8 many) {
|
||||
return (!memcmp (file, "self://", 7));
|
||||
return (!strncmp (file, "self://", 7));
|
||||
}
|
||||
|
||||
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
|
||||
|
@ -75,7 +75,7 @@ static ut64 shm__lseek(RIO *io, RIODesc *fd, ut64 offset, int whence) {
|
||||
}
|
||||
|
||||
static int shm__plugin_open(RIO *io, const char *pathname, ut8 many) {
|
||||
return (!memcmp (pathname, "shm://", 6));
|
||||
return (!strncmp (pathname, "shm://", 6));
|
||||
}
|
||||
|
||||
static inline int getshmid (const char *str) {
|
||||
@ -87,7 +87,7 @@ static inline int getshmfd (RIOShm *shm) {
|
||||
}
|
||||
|
||||
static RIODesc *shm__open(RIO *io, const char *pathname, int rw, int mode) {
|
||||
if (!memcmp (pathname, "shm://", 6)) {
|
||||
if (!strncmp (pathname, "shm://", 6)) {
|
||||
RIOShm *shm = R_NEW (RIOShm);
|
||||
const char *ptr = pathname+6;
|
||||
shm->id = getshmid (ptr);
|
||||
|
@ -40,7 +40,7 @@ static ut64 w32__lseek(RIO *io, RIODesc *fd, ut64 offset, int whence) {
|
||||
}
|
||||
|
||||
static int w32__plugin_open(RIO *io, const char *pathname, ut8 many) {
|
||||
return (!memcmp (pathname, "w32://", 6));
|
||||
return (!strncmp (pathname, "w32://", 6));
|
||||
}
|
||||
|
||||
static inline int getw32fd (RIOW32 *w32) {
|
||||
@ -48,7 +48,7 @@ static inline int getw32fd (RIOW32 *w32) {
|
||||
}
|
||||
|
||||
static RIODesc *w32__open(RIO *io, const char *pathname, int rw, int mode) {
|
||||
if (!memcmp (pathname, "w32://", 6)) {
|
||||
if (!strncmp (pathname, "w32://", 6)) {
|
||||
RIOW32 *w32 = R_NEW (RIOW32);
|
||||
const char *filename= pathname+6;
|
||||
w32->hnd = CreateFile (filename,
|
||||
|
@ -47,9 +47,9 @@ static int __write(struct r_io_t *io, RIODesc *fd, const ut8 *buf, int len) {
|
||||
}
|
||||
|
||||
static int __plugin_open(RIO *io, const char *file, ut8 many) {
|
||||
if (!memcmp (file, "attach://", 9))
|
||||
if (!strncmp (file, "attach://", 9))
|
||||
return R_TRUE;
|
||||
return (!memcmp (file, "w32dbg://", 9))? R_TRUE: R_FALSE;
|
||||
return (!strncmp (file, "w32dbg://", 9))? R_TRUE: R_FALSE;
|
||||
}
|
||||
|
||||
static int __attach (RIOW32Dbg *dbg) {
|
||||
|
Loading…
Reference in New Issue
Block a user