mirror of
https://github.com/rizinorg/rizin.git
synced 2026-10-11 22:19:51 +00:00
rzgdb: Fix oob write in handle_vFile_pread
This commit is contained in:
@@ -30,7 +30,7 @@ int handle_setbp(libgdbr_t *g);
|
||||
int handle_removebp(libgdbr_t *g);
|
||||
int handle_attach(libgdbr_t *g);
|
||||
int handle_vFile_open(libgdbr_t *g);
|
||||
int handle_vFile_pread(libgdbr_t *g, ut8 *buf);
|
||||
int handle_vFile_pread(libgdbr_t *g, ut8 *buf, size_t buf_len);
|
||||
int handle_vFile_close(libgdbr_t *g);
|
||||
int handle_stop_reason(libgdbr_t *g);
|
||||
|
||||
|
||||
@@ -1546,7 +1546,7 @@ int gdbr_pread_file(libgdbr_t *g, ut8 *buf, ut64 max_len, uint32_t start_offset)
|
||||
ret = -1;
|
||||
goto end;
|
||||
}
|
||||
if ((ret1 = handle_vFile_pread(g, buf + ret)) < 0) {
|
||||
if ((ret1 = handle_vFile_pread(g, buf + ret, max_len - ret)) < 0) {
|
||||
ret = ret1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ int handle_vFile_open(libgdbr_t *g) {
|
||||
return send_ack(g);
|
||||
}
|
||||
|
||||
int handle_vFile_pread(libgdbr_t *g, ut8 *buf) {
|
||||
int handle_vFile_pread(libgdbr_t *g, ut8 *buf, size_t buf_len) {
|
||||
send_ack(g);
|
||||
char *ptr;
|
||||
int len;
|
||||
@@ -163,6 +163,8 @@ int handle_vFile_pread(libgdbr_t *g, ut8 *buf) {
|
||||
// Again, this is probably the end of file
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
} else if (len > buf_len) {
|
||||
len = buf_len;
|
||||
}
|
||||
if (!(ptr = strchr(g->data, ';')) || ptr >= g->data + g->data_len) {
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user