aboutsummaryrefslogtreecommitdiffstats
path: root/src/lread.c
diff options
context:
space:
mode:
authorPaul Eggert2011-06-22 09:15:41 -0700
committerPaul Eggert2011-06-22 09:15:41 -0700
commit31fd4b3280acee4030efde84a0e23ae2b006ee31 (patch)
tree0b2245daf7e6f772cbaabf8916faeb34683bb390 /src/lread.c
parentddb7ffeeb8ace6501eb453f50f0f9f6852eda21f (diff)
parent510005210ac9f4d813c4a2cc99b2c3c11e57c055 (diff)
downloademacs-31fd4b3280acee4030efde84a0e23ae2b006ee31.tar.gz
emacs-31fd4b3280acee4030efde84a0e23ae2b006ee31.zip
Merge: Integer overflow and signedness fixes (Bug#8873).
A few related buffer overrun fixes, too.
Diffstat (limited to 'src/lread.c')
-rw-r--r--src/lread.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/lread.c b/src/lread.c
index b789457b223..e75d61ae985 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -158,7 +158,7 @@ static void readevalloop (Lisp_Object, FILE*, Lisp_Object, int,
158static Lisp_Object load_unwind (Lisp_Object); 158static Lisp_Object load_unwind (Lisp_Object);
159static Lisp_Object load_descriptor_unwind (Lisp_Object); 159static Lisp_Object load_descriptor_unwind (Lisp_Object);
160 160
161static void invalid_syntax (const char *, int) NO_RETURN; 161static void invalid_syntax (const char *) NO_RETURN;
162static void end_of_file_error (void) NO_RETURN; 162static void end_of_file_error (void) NO_RETURN;
163 163
164 164
@@ -2014,11 +2014,9 @@ read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end)
2014 S is error string of length N (if > 0) */ 2014 S is error string of length N (if > 0) */
2015 2015
2016static void 2016static void
2017invalid_syntax (const char *s, int n) 2017invalid_syntax (const char *s)
2018{ 2018{
2019 if (!n) 2019 xsignal1 (Qinvalid_read_syntax, build_string (s));
2020 n = strlen (s);
2021 xsignal1 (Qinvalid_read_syntax, make_string (s, n));
2022} 2020}
2023 2021
2024 2022
@@ -2336,7 +2334,7 @@ read_integer (Lisp_Object readcharfun, int radix)
2336 if (! valid) 2334 if (! valid)
2337 { 2335 {
2338 sprintf (buf, "integer, radix %d", radix); 2336 sprintf (buf, "integer, radix %d", radix);
2339 invalid_syntax (buf, 0); 2337 invalid_syntax (buf);
2340 } 2338 }
2341 2339
2342 return string_to_number (buf, radix, 0); 2340 return string_to_number (buf, radix, 0);
@@ -2453,7 +2451,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2453 return ht; 2451 return ht;
2454 } 2452 }
2455 UNREAD (c); 2453 UNREAD (c);
2456 invalid_syntax ("#", 1); 2454 invalid_syntax ("#");
2457 } 2455 }
2458 if (c == '^') 2456 if (c == '^')
2459 { 2457 {
@@ -2487,9 +2485,9 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2487 XSETPVECTYPE (XVECTOR (tmp), PVEC_SUB_CHAR_TABLE); 2485 XSETPVECTYPE (XVECTOR (tmp), PVEC_SUB_CHAR_TABLE);
2488 return tmp; 2486 return tmp;
2489 } 2487 }
2490 invalid_syntax ("#^^", 3); 2488 invalid_syntax ("#^^");
2491 } 2489 }
2492 invalid_syntax ("#^", 2); 2490 invalid_syntax ("#^");
2493 } 2491 }
2494 if (c == '&') 2492 if (c == '&')
2495 { 2493 {
@@ -2513,7 +2511,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2513 version. */ 2511 version. */
2514 && ! (XFASTINT (length) 2512 && ! (XFASTINT (length)
2515 == (SCHARS (tmp) - 1) * BOOL_VECTOR_BITS_PER_CHAR))) 2513 == (SCHARS (tmp) - 1) * BOOL_VECTOR_BITS_PER_CHAR)))
2516 invalid_syntax ("#&...", 5); 2514 invalid_syntax ("#&...");
2517 2515
2518 val = Fmake_bool_vector (length, Qnil); 2516 val = Fmake_bool_vector (length, Qnil);
2519 memcpy (XBOOL_VECTOR (val)->data, SDATA (tmp), size_in_chars); 2517 memcpy (XBOOL_VECTOR (val)->data, SDATA (tmp), size_in_chars);
@@ -2523,7 +2521,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2523 &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1; 2521 &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1;
2524 return val; 2522 return val;
2525 } 2523 }
2526 invalid_syntax ("#&...", 5); 2524 invalid_syntax ("#&...");
2527 } 2525 }
2528 if (c == '[') 2526 if (c == '[')
2529 { 2527 {
@@ -2543,7 +2541,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2543 /* Read the string itself. */ 2541 /* Read the string itself. */
2544 tmp = read1 (readcharfun, &ch, 0); 2542 tmp = read1 (readcharfun, &ch, 0);
2545 if (ch != 0 || !STRINGP (tmp)) 2543 if (ch != 0 || !STRINGP (tmp))
2546 invalid_syntax ("#", 1); 2544 invalid_syntax ("#");
2547 GCPRO1 (tmp); 2545 GCPRO1 (tmp);
2548 /* Read the intervals and their properties. */ 2546 /* Read the intervals and their properties. */
2549 while (1) 2547 while (1)
@@ -2559,7 +2557,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2559 if (ch == 0) 2557 if (ch == 0)
2560 plist = read1 (readcharfun, &ch, 0); 2558 plist = read1 (readcharfun, &ch, 0);
2561 if (ch) 2559 if (ch)
2562 invalid_syntax ("Invalid string property list", 0); 2560 invalid_syntax ("Invalid string property list");
2563 Fset_text_properties (beg, end, plist, tmp); 2561 Fset_text_properties (beg, end, plist, tmp);
2564 } 2562 }
2565 UNGCPRO; 2563 UNGCPRO;
@@ -2716,7 +2714,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2716 return read_integer (readcharfun, 2); 2714 return read_integer (readcharfun, 2);
2717 2715
2718 UNREAD (c); 2716 UNREAD (c);
2719 invalid_syntax ("#", 1); 2717 invalid_syntax ("#");
2720 2718
2721 case ';': 2719 case ';':
2722 while ((c = READCHAR) >= 0 && c != '\n'); 2720 while ((c = READCHAR) >= 0 && c != '\n');
@@ -2833,7 +2831,7 @@ read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2833 if (ok) 2831 if (ok)
2834 return make_number (c); 2832 return make_number (c);
2835 2833
2836 invalid_syntax ("?", 1); 2834 invalid_syntax ("?");
2837 } 2835 }
2838 2836
2839 case '"': 2837 case '"':
@@ -3335,7 +3333,7 @@ string_to_number (char const *string, int base, int ignore_trailing)
3335 /* Unfortunately there's no simple and accurate way to convert 3333 /* Unfortunately there's no simple and accurate way to convert
3336 non-base-10 numbers that are out of C-language range. */ 3334 non-base-10 numbers that are out of C-language range. */
3337 if (base != 10) 3335 if (base != 10)
3338 xsignal (Qoverflow_error, list1 (build_string (string))); 3336 xsignal1 (Qoverflow_error, build_string (string));
3339 } 3337 }
3340 else if (n <= (negative ? -MOST_NEGATIVE_FIXNUM : MOST_POSITIVE_FIXNUM)) 3338 else if (n <= (negative ? -MOST_NEGATIVE_FIXNUM : MOST_POSITIVE_FIXNUM))
3341 { 3339 {
@@ -3501,7 +3499,7 @@ read_list (int flag, register Lisp_Object readcharfun)
3501 { 3499 {
3502 if (ch == ']') 3500 if (ch == ']')
3503 return val; 3501 return val;
3504 invalid_syntax (") or . in a vector", 18); 3502 invalid_syntax (") or . in a vector");
3505 } 3503 }
3506 if (ch == ')') 3504 if (ch == ')')
3507 return val; 3505 return val;
@@ -3603,9 +3601,9 @@ read_list (int flag, register Lisp_Object readcharfun)
3603 3601
3604 return val; 3602 return val;
3605 } 3603 }
3606 invalid_syntax (". in wrong context", 18); 3604 invalid_syntax (". in wrong context");
3607 } 3605 }
3608 invalid_syntax ("] in a list", 11); 3606 invalid_syntax ("] in a list");
3609 } 3607 }
3610 tem = (read_pure && flag <= 0 3608 tem = (read_pure && flag <= 0
3611 ? pure_cons (elt, Qnil) 3609 ? pure_cons (elt, Qnil)
@@ -3652,7 +3650,7 @@ Lisp_Object
3652intern (const char *str) 3650intern (const char *str)
3653{ 3651{
3654 Lisp_Object tem; 3652 Lisp_Object tem;
3655 int len = strlen (str); 3653 ptrdiff_t len = strlen (str);
3656 Lisp_Object obarray; 3654 Lisp_Object obarray;
3657 3655
3658 obarray = Vobarray; 3656 obarray = Vobarray;
@@ -3668,7 +3666,7 @@ Lisp_Object
3668intern_c_string (const char *str) 3666intern_c_string (const char *str)
3669{ 3667{
3670 Lisp_Object tem; 3668 Lisp_Object tem;
3671 int len = strlen (str); 3669 ptrdiff_t len = strlen (str);
3672 Lisp_Object obarray; 3670 Lisp_Object obarray;
3673 3671
3674 obarray = Vobarray; 3672 obarray = Vobarray;