mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
7073913: The fix for 7017193 causes segfaults
Buffer overflow in os::get_line_chars Reviewed-by: coleenp, dholmes, dcubed
This commit is contained in:
parent
28383f3e18
commit
aefb3a004f
1 changed files with 2 additions and 2 deletions
|
@ -1299,7 +1299,7 @@ int os::get_line_chars(int fd, char* buf, const size_t bsize){
|
||||||
size_t sz, i = 0;
|
size_t sz, i = 0;
|
||||||
|
|
||||||
// read until EOF, EOL or buf is full
|
// read until EOF, EOL or buf is full
|
||||||
while ((sz = (int) read(fd, &buf[i], 1)) == 1 && i < (bsize-1) && buf[i] != '\n') {
|
while ((sz = (int) read(fd, &buf[i], 1)) == 1 && i < (bsize-2) && buf[i] != '\n') {
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1320,7 +1320,7 @@ int os::get_line_chars(int fd, char* buf, const size_t bsize){
|
||||||
}
|
}
|
||||||
|
|
||||||
// line is longer than size of buf, skip to EOL
|
// line is longer than size of buf, skip to EOL
|
||||||
int ch;
|
char ch;
|
||||||
while (read(fd, &ch, 1) == 1 && ch != '\n') {
|
while (read(fd, &ch, 1) == 1 && ch != '\n') {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue