<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/py/vstr.c, branch encoding</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=encoding</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=encoding'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2020-07-06T18:16:25+00:00</updated>
<entry>
<title>Add license to some obvious files.</title>
<updated>2020-07-06T18:16:25+00:00</updated>
<author>
<name>Diego Elio Pettenò</name>
<email>flameeyes@flameeyes.com</email>
</author>
<published>2020-06-03T22:40:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=34b4993d63a6b576f29d624385c681f679b4124c'/>
<id>urn:sha1:34b4993d63a6b576f29d624385c681f679b4124c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>style</title>
<updated>2020-01-08T22:36:43+00:00</updated>
<author>
<name>Jeff Epler</name>
<email>jepler@gmail.com</email>
</author>
<published>2020-01-08T22:36:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=f1c2dee1c05227d63e3833cb10d6fe99b9bd5092'/>
<id>urn:sha1:f1c2dee1c05227d63e3833cb10d6fe99b9bd5092</id>
<content type='text'>
</content>
</entry>
<entry>
<title>vstr_init_len: Don't crash if (size_t)-1 is passed</title>
<updated>2020-01-08T15:42:44+00:00</updated>
<author>
<name>Jeff Epler</name>
<email>jepler@gmail.com</email>
</author>
<published>2020-01-08T15:42:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=5baaac55ce2b9fb89c1f395e92f67abb5276ce6f'/>
<id>urn:sha1:5baaac55ce2b9fb89c1f395e92f67abb5276ce6f</id>
<content type='text'>
In this unusual case, (len + 1) is zero, the allocation in vstr_init
succeeds (allocating 1 byte), and then the caller is likely to erroneously
access outside the allocated region, for instance with a memset().

This could be triggered with os.urandom(-1) after it was converted to use
mp_obj_new_bytes_of_zeros.
</content>
</entry>
<entry>
<title>py/vstr: Raise a RuntimeError if fixed vstr buffer overflows.</title>
<updated>2017-09-21T10:29:41+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-08-31T22:05:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=ede8a0235b47333aaaa8d03a3b9e20b014be3808'/>
<id>urn:sha1:ede8a0235b47333aaaa8d03a3b9e20b014be3808</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>all: Use the name MicroPython consistently in comments</title>
<updated>2017-07-31T08:35:40+00:00</updated>
<author>
<name>Alexander Steffen</name>
<email>devel.20.webmeister@spamgourmet.com</email>
</author>
<published>2017-06-30T07:22:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=55f33240f3d7051d4213629e92437a36f1fac50e'/>
<id>urn:sha1:55f33240f3d7051d4213629e92437a36f1fac50e</id>
<content type='text'>
There were several different spellings of MicroPython present in comments,
when there should be only one.
</content>
</entry>
<entry>
<title>py,extmod: Some casts and minor refactors to quiet compiler warnings.</title>
<updated>2017-07-07T01:32:22+00:00</updated>
<author>
<name>Tom Collins</name>
<email>tom.collins@digi.com</email>
</author>
<published>2017-06-30T23:23:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=145796f037715e180b441b38c1ec1ba45ff77797'/>
<id>urn:sha1:145796f037715e180b441b38c1ec1ba45ff77797</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py/vstr: Combine vstr_new_size with vstr_new since they are rarely used.</title>
<updated>2016-10-14T05:46:34+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-10-14T05:46:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=824f5c5a32d740acad50d23b7ab1d69660dcf3ad'/>
<id>urn:sha1:824f5c5a32d740acad50d23b7ab1d69660dcf3ad</id>
<content type='text'>
Now there is just one function to allocate a new vstr, namely vstr_new
(in addition to vstr_init etc).  The caller of this function should know
what initial size to allocate for the buffer, or at least have some policy
or config option, instead of leaving it to a default (as it was before).
</content>
</entry>
<entry>
<title>py/vstr: Remove vstr.had_error flag and inline basic vstr functions.</title>
<updated>2016-09-19T02:28:55+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-09-19T01:17:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=5da0d29d3cefa6a3cac52e0db96e9ede820d6a51'/>
<id>urn:sha1:5da0d29d3cefa6a3cac52e0db96e9ede820d6a51</id>
<content type='text'>
The vstr.had_error flag was a relic from the very early days which assumed
that the malloc functions (eg m_new, m_renew) returned NULL if they failed
to allocate.  But that's no longer the case: these functions will raise an
exception if they fail.

Since it was impossible for had_error to be set, this patch introduces no
change in behaviour.

An alternative option would be to change the malloc calls to the _maybe
variants, which return NULL instead of raising, but then a lot of code
will need to explicitly check if the vstr had an error and raise if it
did.

The code-size savings for this patch are, in bytes: bare-arm:188,
minimal:456, unix(NDEBUG,x86-64):368, stmhal:228, esp8266:360.
</content>
</entry>
<entry>
<title>py/vstr: Change allocation policy, +16 to requested size, instead of *2.</title>
<updated>2016-05-09T21:56:51+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2016-05-09T21:56:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=6f34e138f1ecf197212dc1392cbffeea41b44a93'/>
<id>urn:sha1:6f34e138f1ecf197212dc1392cbffeea41b44a93</id>
<content type='text'>
Effect measured on esp8266 port:

Before:
&gt;&gt;&gt; pystone_lowmem.main(10000)
Pystone(1.2) time for 10000 passes = 44214 ms
This machine benchmarks at 226 pystones/second
&gt;&gt;&gt; pystone_lowmem.main(10000)
Pystone(1.2) time for 10000 passes = 44246 ms
This machine benchmarks at 226 pystones/second

After:
&gt;&gt;&gt; pystone_lowmem.main(10000)
Pystone(1.2) time for 10000 passes = 44343ms
This machine benchmarks at 225 pystones/second
&gt;&gt;&gt; pystone_lowmem.main(10000)
Pystone(1.2) time for 10000 passes = 44376ms
This machine benchmarks at 225 pystones/second
</content>
</entry>
<entry>
<title>py/vstr: vstr_null_terminated_str(): Extend string by at most one byte.</title>
<updated>2016-05-09T19:39:57+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2016-05-09T19:39:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=a1f2245a81cb9e99cc620797e54a003bf0907b16'/>
<id>urn:sha1:a1f2245a81cb9e99cc620797e54a003bf0907b16</id>
<content type='text'>
vstr_null_terminated_str is almost certainly a vstr finalization operation,
so it should add the requested NUL byte, and not try to pre-allocate more.
The previous implementation could actually allocate double of the buffer
size.
</content>
</entry>
</feed>
