mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +00:00
fix scanf
buffer overflow
This commit is contained in:
parent
7fff96dc61
commit
7967852eb9
@ -184,10 +184,16 @@ static bool builtins_input(int argc, py_Ref argv) {
|
||||
prompt = py_tostr(argv);
|
||||
}
|
||||
printf("%s", prompt);
|
||||
char buf[2048];
|
||||
scanf("%s", buf);
|
||||
getchar();
|
||||
py_newstr(py_retval(), buf);
|
||||
|
||||
c11_sbuf buf;
|
||||
c11_sbuf__ctor(&buf);
|
||||
while(true) {
|
||||
int c = getchar();
|
||||
if(c == '\n') break;
|
||||
if(c == EOF) break;
|
||||
c11_sbuf__write_char(&buf, c);
|
||||
}
|
||||
c11_sbuf__py_submit(&buf, py_retval());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user