summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-01-21 09:28:18 -0800
committerGitHub <noreply@github.com>2019-01-21 09:28:18 -0800
commit9e8d182fe14c05b3e7c6a74e35987ec293310c7a (patch)
treeb8fac14457fc64125e3642ee061e18b5dac1edfe /shared-module
parent92dd9072cda89d41cfe6eeabbce9907bf68b137e (diff)
parent777408ff8d45b9a73dbf0bcf8c083ade0b5152e5 (diff)
Merge pull request #1480 from dhalbert/packinto-bug
struct.pack_into incorrect buffer size check
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/struct/__init__.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/shared-module/struct/__init__.c b/shared-module/struct/__init__.c
index 28e7c0c3f..245dbbda9 100644
--- a/shared-module/struct/__init__.c
+++ b/shared-module/struct/__init__.c
@@ -124,8 +124,8 @@ void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte* end_p, size
char fmt_type = get_fmt_type(&fmt);
const mp_uint_t total_sz = shared_modules_struct_calcsize(fmt_in);
- if (p + total_sz != end_p) {
- mp_raise_msg_varg(&mp_type_RuntimeError, translate("unpack requires a buffer of %d bytes"), total_sz);
+ if (p + total_sz > end_p) {
+ mp_raise_RuntimeError(translate("buffer too small"));
}
size_t i;