Skip to content

Commit 0463fb7

Browse files
committed
Fix heap-buffer-overflow when reading null bytes
1 parent da65f38 commit 0463fb7

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed heap-buffer-overflow in PyOS_StdioReadline when encountering null
2+
bytes in interactive input. Patch by Shamil Abdulaev.

Parser/myreadline.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, const char *prompt)
344344
break;
345345
}
346346
n += strlen(p + n);
347-
} while (p[n-1] != '\n');
347+
} while (n > 0 && p[n-1] != '\n');
348348

349349
pr = (char *)PyMem_RawRealloc(p, n+1);
350350
if (pr == NULL) {

0 commit comments

Comments
 (0)