https://gcc.gnu.org/g:c6e7d9ca72cb424b7af9357d77209eb7dd14621a

commit r15-8866-gc6e7d9ca72cb424b7af9357d77209eb7dd14621a
Author: Andreas Schwab <sch...@suse.de>
Date:   Mon Mar 24 11:39:29 2025 +0100

    Remove buffer overflow in cobol driver
    
            PR cobol/119390
            * gcobolspec.cc (lang_specific_driver): Use pointer instead of
            copying into fixed array.

Diff:
---
 gcc/cobol/gcobolspec.cc | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/gcc/cobol/gcobolspec.cc b/gcc/cobol/gcobolspec.cc
index 364c14c8a700..c84f4058c59d 100644
--- a/gcc/cobol/gcobolspec.cc
+++ b/gcc/cobol/gcobolspec.cc
@@ -498,15 +498,11 @@ lang_specific_driver (struct cl_decoded_option 
**in_decoded_options,
 
           if( prior_main )
             {
-            char ach[128];
-            if( entry_point )
-              {
-              strcpy(ach, entry_point);
-              }
+            const char *ach;
+            if (entry_point)
+             ach = entry_point;
             else
-              {
-              strcpy(ach, decoded_options[i].arg);
-              }
+             ach = decoded_options[i].arg;
             append_option(OPT_main_, ach, 1);
             prior_main = false;
             entry_point = NULL;

Reply via email to