aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/libgnat/s-imgrea.adb
diff options
context:
space:
mode:
authorSteve Baird <baird@adacore.com>2020-01-17 22:10:13 -0800
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-04 05:10:59 -0400
commitb5682bf40cedf95d1e0150c6a6ba7a64c59fd968 (patch)
tree8a859c90f9b28e936ef5d91c4bbb5b8220a8a319 /gcc/ada/libgnat/s-imgrea.adb
parentb68c1670b7d40b09be2995e1e730ce4c87eb688c (diff)
downloadgcc-b5682bf40cedf95d1e0150c6a6ba7a64c59fd968.zip
gcc-b5682bf40cedf95d1e0150c6a6ba7a64c59fd968.tar.gz
gcc-b5682bf40cedf95d1e0150c6a6ba7a64c59fd968.tar.bz2
[Ada] Avoid buffer overflow in Long_Long_Float_Text_IO
2020-06-04 Steve Baird <baird@adacore.com> gcc/ada/ * libgnat/s-imgrea.ads: Declare a named number Max_Real_Image_Length with value 5200. Provide a comment explaining why this value was chosen. * libgnat/s-imgrea.adb (Set_Image_Real): Increase the upper bound of the local String variable Digs to Max_Real_Image_Length. * libgnat/a-tiflau.adb (Put): Increase the upper bound of the local String variable Buf to Max_Real_Image_Length. (Puts): Increase the upper bound of the local String variable Buf to Max_Real_Image_Length.
Diffstat (limited to 'gcc/ada/libgnat/s-imgrea.adb')
-rw-r--r--gcc/ada/libgnat/s-imgrea.adb11
1 files changed, 3 insertions, 8 deletions
diff --git a/gcc/ada/libgnat/s-imgrea.adb b/gcc/ada/libgnat/s-imgrea.adb
index 642724b..68b1fdc 100644
--- a/gcc/ada/libgnat/s-imgrea.adb
+++ b/gcc/ada/libgnat/s-imgrea.adb
@@ -151,14 +151,9 @@ package body System.Img_Real is
Scale : Integer;
Expon : Integer;
- Field_Max : constant := 255;
- -- This should be the same value as Ada.[Wide_]Text_IO.Field'Last.
- -- It is not worth dragging in Ada.Text_IO to pick up this value,
- -- since it really should never be necessary to change it.
-
- Digs : String (1 .. 2 * Field_Max + 16);
- -- Array used to hold digits of converted integer value. This is a
- -- large enough buffer to accommodate ludicrous values of Fore and Aft.
+ Digs : String (1 .. Max_Real_Image_Length);
+ -- Array used to hold digits of converted integer value. This is a large
+ -- enough buffer to accommodate ludicrous Fore/Aft/Exp combinations.
Ndigs : Natural;
-- Number of digits stored in Digs (and also subscript of last digit)