Skip to content

Commit

Permalink
fix #2953 - oob read in magic/funcs.c
Browse files Browse the repository at this point in the history
  • Loading branch information
wargio committed Aug 22, 2022
1 parent 5b5715d commit 04b97d2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion librz/magic/funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ const char *file_getbuffer(RzMagic *ms) {
file_oomem(ms, psize);
return NULL;
}
pbuf[psize - 1] = 0;
ms->o.pbuf = pbuf;

#if 1
Expand Down Expand Up @@ -307,7 +308,9 @@ const char *file_getbuffer(RzMagic *ms) {
}
}
#endif
for (np = ms->o.pbuf, op = ms->o.buf; *op; op++) {
const char *pbuf_end = ms->o.pbuf + psize;
const char *buf_end = ms->o.buf + len;
for (np = ms->o.pbuf, op = ms->o.buf; op < buf_end && np < pbuf_end && *op; op++) {
if (isprint((ut8)*op)) {
*np++ = *op;
} else {
Expand Down

0 comments on commit 04b97d2

Please sign in to comment.