mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-04 11:43:39 +00:00
Fix return value for RBuffer.sparse when reading beyond the end
This commit is contained in:
parent
ab6aa52c23
commit
cf7dcf07dc
@ -293,6 +293,10 @@ R_API bool r_anal_set_bits(RAnal *anal, int bits) {
|
||||
R_API void r_anal_set_cpu(RAnal *anal, const char *cpu) {
|
||||
free (anal->cpu);
|
||||
anal->cpu = cpu ? strdup (cpu) : NULL;
|
||||
int v = r_anal_archinfo (anal, R_ANAL_ARCHINFO_ALIGN);
|
||||
if (v != -1) {
|
||||
anal->pcalign = v;
|
||||
}
|
||||
}
|
||||
|
||||
R_API int r_anal_set_big_endian(RAnal *anal, int bigend) {
|
||||
|
@ -178,10 +178,7 @@ static int __read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
|
||||
}
|
||||
Rihex *rih = fd->data;
|
||||
memset (buf, io->Oxff, count);
|
||||
if (r_buf_read_at (rih->rbuf, io->off, buf, count) != count) {
|
||||
return -1; //should never happen with a sparsebuf..
|
||||
}
|
||||
return count;
|
||||
return r_buf_read_at (rih->rbuf, io->off, buf, count);
|
||||
}
|
||||
|
||||
static int __close(RIODesc *fd) {
|
||||
@ -378,7 +375,7 @@ static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
|
||||
if (!str) {
|
||||
return NULL;
|
||||
}
|
||||
mal= R_NEW0 (Rihex);
|
||||
mal = R_NEW0 (Rihex);
|
||||
if (!mal) {
|
||||
free (str);
|
||||
return NULL;
|
||||
|
@ -498,6 +498,7 @@ static int r_buf_cpy(RBuffer *b, ut64 addr, ut8 *dst, const ut8 *src, int len, i
|
||||
// read from sparse and write into dst
|
||||
memset (dst, b->Oxff, len);
|
||||
(void)sparse_read (b->sparse, addr, dst, len);
|
||||
len = R_MIN (len , r_buf_size (b) - addr);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user