summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Gorrod <alexander.gorrod@mongodb.com>2015-03-19 13:53:01 +1100
committerAlex Gorrod <alexander.gorrod@mongodb.com>2015-03-19 13:53:01 +1100
commitb6ac393cda62f6a964ac90c1b9427eea842a2109 (patch)
tree830cb09431ce251362ee9c75c9f8d31858cafefd /src
parent6223e0707e258c8fc5c6c72b4825146889db8353 (diff)
parenta2e270381f103709c865db8249e41213c888b31f (diff)
downloadmongo-b6ac393cda62f6a964ac90c1b9427eea842a2109.tar.gz
Merge pull request #1781 from wiredtiger/pack-stream-length-check
Add length checks to the WT_PACK_STREAM API
Diffstat (limited to 'src')
-rw-r--r--src/packing/pack_stream.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/packing/pack_stream.c b/src/packing/pack_stream.c
index 739e803b88c..1f3449d79d3 100644
--- a/src/packing/pack_stream.c
+++ b/src/packing/pack_stream.c
@@ -83,6 +83,10 @@ wiredtiger_pack_item(WT_PACK_STREAM *ps, WT_ITEM *item)
session = ps->pack.session;
+ /* Lower-level packing routines treat a length of zero as unchecked. */
+ if (ps->p >= ps->end)
+ return (ENOMEM);
+
WT_RET(__pack_next(&ps->pack, &pv));
switch (pv.type) {
case 'U':
@@ -110,6 +114,10 @@ wiredtiger_pack_int(WT_PACK_STREAM *ps, int64_t i)
session = ps->pack.session;
+ /* Lower-level packing routines treat a length of zero as unchecked. */
+ if (ps->p >= ps->end)
+ return (ENOMEM);
+
WT_RET(__pack_next(&ps->pack, &pv));
switch (pv.type) {
case 'b':
@@ -139,6 +147,10 @@ wiredtiger_pack_str(WT_PACK_STREAM *ps, const char *s)
session = ps->pack.session;
+ /* Lower-level packing routines treat a length of zero as unchecked. */
+ if (ps->p >= ps->end)
+ return (ENOMEM);
+
WT_RET(__pack_next(&ps->pack, &pv));
switch (pv.type) {
case 'S':
@@ -165,6 +177,10 @@ wiredtiger_pack_uint(WT_PACK_STREAM *ps, uint64_t u)
session = ps->pack.session;
+ /* Lower-level packing routines treat a length of zero as unchecked. */
+ if (ps->p >= ps->end)
+ return (ENOMEM);
+
WT_RET(__pack_next(&ps->pack, &pv));
switch (pv.type) {
case 'B':
@@ -197,6 +213,10 @@ wiredtiger_unpack_item(WT_PACK_STREAM *ps, WT_ITEM *item)
session = ps->pack.session;
+ /* Lower-level packing routines treat a length of zero as unchecked. */
+ if (ps->p >= ps->end)
+ return (ENOMEM);
+
WT_RET(__pack_next(&ps->pack, &pv));
switch (pv.type) {
case 'U':
@@ -224,6 +244,10 @@ wiredtiger_unpack_int(WT_PACK_STREAM *ps, int64_t *ip)
session = ps->pack.session;
+ /* Lower-level packing routines treat a length of zero as unchecked. */
+ if (ps->p >= ps->end)
+ return (ENOMEM);
+
WT_RET(__pack_next(&ps->pack, &pv));
switch (pv.type) {
case 'b':
@@ -252,6 +276,10 @@ wiredtiger_unpack_str(WT_PACK_STREAM *ps, const char **sp)
session = ps->pack.session;
+ /* Lower-level packing routines treat a length of zero as unchecked. */
+ if (ps->p >= ps->end)
+ return (ENOMEM);
+
WT_RET(__pack_next(&ps->pack, &pv));
switch (pv.type) {
case 'S':
@@ -277,6 +305,10 @@ wiredtiger_unpack_uint(WT_PACK_STREAM *ps, uint64_t *up)
session = ps->pack.session;
+ /* Lower-level packing routines treat a length of zero as unchecked. */
+ if (ps->p >= ps->end)
+ return (ENOMEM);
+
WT_RET(__pack_next(&ps->pack, &pv));
switch (pv.type) {
case 'B':