From 28f49d525258432f68248c880ae574bb87db948a Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 11 Nov 2012 14:36:11 +0900 Subject: [PATCH] Fixing potential buffer overflow. --- sexp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sexp.c b/sexp.c index a71f086f..000e620c 100644 --- a/sexp.c +++ b/sexp.c @@ -2150,7 +2150,7 @@ sexp sexp_read_string (sexp ctx, sexp in, int sentinel) { len = sexp_utf8_char_byte_count(c); sexp_utf8_encode_char((unsigned char*)buf + i, len, c); i += len; - continue; + goto maybe_expand; } #endif } @@ -2168,6 +2168,7 @@ sexp sexp_read_string (sexp ctx, sexp in, int sentinel) { break; } buf[i++] = c; + maybe_expand: if (i+4 >= size) { /* expand buffer w/ malloc(), later free() it */ tmp = (char*) sexp_malloc(size*2); if (!tmp) {res = sexp_global(ctx, SEXP_G_OOM_ERROR); break;}