aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2011-09-08 16:31:45 +0200
committerHenrik Nord <[email protected]>2011-09-08 16:31:49 +0200
commitb65eb33effd41e3421acdc46bb5b6495c814d2b7 (patch)
treec361fcc3f241afb0603493f6c1861fce16caa7ba /lib
parentb9cc262cb672c70a3031d9feb66ea428dafe796d (diff)
parent9cf9cde066d26569178f5f67600278ae67e102dd (diff)
downloadotp-b65eb33effd41e3421acdc46bb5b6495c814d2b7.tar.gz
otp-b65eb33effd41e3421acdc46bb5b6495c814d2b7.tar.bz2
otp-b65eb33effd41e3421acdc46bb5b6495c814d2b7.zip
Merge branch 'ms/ei-int-overflow-in-string-atom-enc' into dev
* ms/ei-int-overflow-in-string-atom-enc: ei: integer overflow in string/atom encoding OTP-9530
Diffstat (limited to 'lib')
-rw-r--r--lib/erl_interface/src/encode/encode_atom.c6
-rw-r--r--lib/erl_interface/src/encode/encode_string.c6
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/erl_interface/src/encode/encode_atom.c b/lib/erl_interface/src/encode/encode_atom.c
index 69f2d1451c..b1a4479034 100644
--- a/lib/erl_interface/src/encode/encode_atom.c
+++ b/lib/erl_interface/src/encode/encode_atom.c
@@ -17,13 +17,17 @@
* %CopyrightEnd%
*/
#include <string.h>
+#include <limits.h>
#include "eidef.h"
#include "eiext.h"
#include "putget.h"
int ei_encode_atom(char *buf, int *index, const char *p)
{
- return ei_encode_atom_len(buf, index, p, strlen(p));
+ size_t len = strlen(p);
+
+ if (len >= INT_MAX) return -1;
+ return ei_encode_atom_len(buf, index, p, len);
}
int ei_encode_atom_len(char *buf, int *index, const char *p, int len)
diff --git a/lib/erl_interface/src/encode/encode_string.c b/lib/erl_interface/src/encode/encode_string.c
index 1d342cb605..593bbf2b6d 100644
--- a/lib/erl_interface/src/encode/encode_string.c
+++ b/lib/erl_interface/src/encode/encode_string.c
@@ -17,6 +17,7 @@
* %CopyrightEnd%
*/
#include <string.h>
+#include <limits.h>
#include "eidef.h"
#include "eiext.h"
#include "putget.h"
@@ -24,7 +25,10 @@
int ei_encode_string(char *buf, int *index, const char *p)
{
- return ei_encode_string_len(buf, index, p, strlen(p));
+ size_t len = strlen(p);
+
+ if (len >= INT_MAX) return -1;
+ return ei_encode_string_len(buf, index, p, len);
}
int ei_encode_string_len(char *buf, int *index, const char *p, int len)