diff --git a/doc/fortunes b/doc/fortunes index a3e90d38dc..a1a75c9668 100644 --- a/doc/fortunes +++ b/doc/fortunes @@ -123,3 +123,6 @@ You are probably using an old version of r2, go checkout the git! Run your own r2 scripts in awk using the r2awk program I love gradients Use -e bin.strings=false to disable search for strings when loading the binary +wait a moment.. +Don't do this. +No such file or directory. diff --git a/libr/cons/line.c b/libr/cons/line.c index 75ecf61161..88dc4e6272 100644 --- a/libr/cons/line.c +++ b/libr/cons/line.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2007-2012 pancake */ +/* radare - LGPL - Copyright 2007-2013 - pancake */ #include diff --git a/libr/cons/pipe.c b/libr/cons/pipe.c index af3f6c90f6..297a9f97d5 100644 --- a/libr/cons/pipe.c +++ b/libr/cons/pipe.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2009-2012 - pancake */ +/* radare - LGPL - Copyright 2009-2013 - pancake */ #include #include @@ -13,12 +13,12 @@ static int backup_fd = -1; #endif R_API int r_cons_pipe_open(const char *file, int append) { - int fd = open (file, O_BINARY | O_RDWR | O_CREAT | (append?O_APPEND:O_TRUNC), 0644); + int fd = r_sandbox_open (file, + O_BINARY | O_RDWR | O_CREAT | (append?O_APPEND:O_TRUNC), 0644); if (fd==-1) { eprintf ("r_cons_pipe_open: Cannot open file '%s'\n", file); return -1; }// else eprintf ("%s created\n", file); - if (backup_fd != -1) close (backup_fd); #if __WINDOWS__ diff --git a/libr/include/r_util.h b/libr/include/r_util.h index 9cf15166f6..bc7091e6b9 100644 --- a/libr/include/r_util.h +++ b/libr/include/r_util.h @@ -236,6 +236,7 @@ R_API ut64 r_num_chs (int cylinder, int head, int sector, int sectorsize); #define R_BUF_CUR -1 R_API RBuffer *r_buf_new(); +R_API RBuffer *r_buf_file (const char *file); R_API RBuffer *r_buf_mmap (const char *file, int rw); R_API int r_buf_set_bits(RBuffer *b, int bitoff, int bitsize, ut64 value); R_API int r_buf_set_bytes(RBuffer *b, const ut8 *buf, int length); diff --git a/libr/util/buf.c b/libr/util/buf.c index b1c4d9c064..b9e24893bc 100644 --- a/libr/util/buf.c +++ b/libr/util/buf.c @@ -40,6 +40,17 @@ R_API RBuffer *r_buf_mmap (const char *file, int rw) { return b; } +R_API RBuffer *r_buf_file (const char *file) { + RBuffer *b = r_buf_new (); + if (!b) return NULL; + b->buf = (ut8*)r_file_slurp (file, &b->length); + if (!b->buf) { + r_buf_free (b); + return NULL; /* we just freed b, don't return it */ + } + return b; +} + R_API int r_buf_set_bits(RBuffer *b, int bitoff, int bitsize, ut64 value) { // TODO: implement r_buf_set_bits // TODO: get the implementation from reg/value.c ? diff --git a/libr/util/file.c b/libr/util/file.c index 1cc9e1bfe3..32519e77b6 100644 --- a/libr/util/file.c +++ b/libr/util/file.c @@ -48,7 +48,7 @@ R_API char *r_file_abspath(const char *file) { ret = r_str_dup_printf ("%s/%s", cwd, file); #elif __WINDOWS__ if (cwd && !strchr (file, ':')) - ret = r_str_dup_printf ("%s/%s", cwd, file); + ret = r_str_dup_printf ("%s\\%s", cwd, file); #endif free (cwd); // TODO: remove // and ./ @@ -277,8 +277,10 @@ R_API RMmap *r_file_mmap (const char *file, boolt rw) { } #elif __WINDOWS__ close (fd); - m->fh = CreateFile (file, rw?GENERIC_WRITE:GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0); - if (m->fh == NULL) { + m->fh = CreateFile (file, rw?GENERIC_WRITE:GENERIC_READ, + FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); + if (m->fh == INVALID_HANDLE_FILE) { + r_sys_perror ("CreateFile"); free (m); return NULL; } @@ -290,7 +292,8 @@ R_API RMmap *r_file_mmap (const char *file, boolt rw) { return NULL; } if (m->fm != INVALID_HANDLE_VALUE) { - m->buf = MapViewOfFile (m->fm, rw?FILE_MAP_READ|FILE_MAP_WRITE:FILE_MAP_READ, 0, 0, 0); + m->buf = MapViewOfFile (m->fm, rw? + FILE_MAP_READ|FILE_MAP_WRITE:FILE_MAP_READ, 0, 0, 0); } else { CloseHandle (m->fh); free (m); diff --git a/libr/util/sandbox.c b/libr/util/sandbox.c index 116d967337..c063e4b091 100644 --- a/libr/util/sandbox.c +++ b/libr/util/sandbox.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2012 - pancake */ +/* radare - LGPL - Copyright 2012-2013 - pancake */ #include #include @@ -51,6 +51,9 @@ R_API int r_sandbox_open (const char *path, int mode, int perm) { if (!r_sandbox_check_path (path)) return -1; } +#if __WINDOWS__ + perm = 0; +#endif return open (path, mode, perm); } diff --git a/shlr/www/enyo/js/r2.js b/shlr/www/enyo/js/r2.js index 501ada7792..5104ba076f 100644 --- a/shlr/www/enyo/js/r2.js +++ b/shlr/www/enyo/js/r2.js @@ -78,7 +78,7 @@ r2.get_flags = function (fn) { r2.get_opcodes = function (off, n, cb) { r2.cmd ("pdj @"+off+"!"+n, function (json) { - cb (JSON.parse (o)); + cb (JSON.parse (json)); }); }