micropython/tests/unix/extra_coverage.py.exp
Damien George ede8a0235b py/vstr: Raise a RuntimeError if fixed vstr buffer overflows.
Current users of fixed vstr buffers (building file paths) assume that there
is no overflow and do not check for overflow after building the vstr.  This
has the potential to lead to NULL pointer dereferences
(when vstr_null_terminated_str returns NULL because it can't allocate RAM
for the terminating byte) and stat'ing and loading invalid path names (due
to the path being truncated).  The safest and simplest thing to do in these
cases is just raise an exception if a write goes beyond the end of a fixed
vstr buffer, which is what this patch does.  It also simplifies the vstr
code.
2017-09-21 20:29:41 +10:00

93 lines
998 B
Plaintext

# mp_printf
-123 +123 123
-0123
123
1ABCDEF
ab abc
false true
(null)
-2147483648
2147483648
80000000
80000000
abc
# vstr
tests
sts
test
tes
RuntimeError:
RuntimeError:
# repl
ame__
__name__ path argv version
version_info implementation platform byteorder
maxsize exit stdin stdout
stderr modules exc_info getsizeof
print_exception
ementation
# attrtuple
(start=1, stop=2, step=3)
# str
1
# mpz
1
12345678
0
0
# runtime utils
TypeError: unsupported type for : 'str'
TypeError: unsupported types for : 'str', 'str'
Warning: test
# format float
?
+1e+00
+1e+00
# binary
122
456
# scheduler
sched(0)=1
sched(1)=1
sched(2)=1
sched(3)=1
sched(4)=0
unlocked
3
2
1
0
0123456789 b'0123456789'
7300
7300
7300
7300
None
None
None
None
None
None
b'123'
b'123'
b'123'
OSError
0
OSError
None
None
frzstr1
frzmpy1
frzstr_pkg1.__init__
1
frzmpy_pkg1.__init__
1
frzstr_pkg2.mod
1
frzmpy_pkg2.mod
1
ZeroDivisionError