zap strcpy/strcat/sprintf in gfortran.
This commit is contained in:
parent
58ff23521e
commit
0961beec67
42
lang/gcc/4.0/patches/patch-libgfortran_io_list_read_c
Normal file
42
lang/gcc/4.0/patches/patch-libgfortran_io_list_read_c
Normal file
@ -0,0 +1,42 @@
|
||||
$OpenBSD: patch-libgfortran_io_list_read_c,v 1.1 2005/06/16 18:04:41 espie Exp $
|
||||
--- libgfortran/io/list_read.c.orig Thu Jun 16 19:20:22 2005
|
||||
+++ libgfortran/io/list_read.c Thu Jun 16 19:22:37 2005
|
||||
@@ -1656,8 +1656,8 @@ nml_touch_nodes (namelist_info * nl)
|
||||
index_type len = strlen (nl->var_name) + 1;
|
||||
int dim;
|
||||
char * ext_name = (char*)get_mem (len + 1);
|
||||
- strcpy (ext_name, nl->var_name);
|
||||
- strcat (ext_name, "%");
|
||||
+ strlcpy (ext_name, nl->var_name, len + 1);
|
||||
+ strlcat (ext_name, "%", len + 1);
|
||||
for (nl = nl->next; nl; nl = nl->next)
|
||||
{
|
||||
if (strncmp (nl->var_name, ext_name, len) == 0)
|
||||
@@ -1900,8 +1900,8 @@ nml_read_obj (namelist_info * nl, index_
|
||||
case GFC_DTYPE_DERIVED:
|
||||
obj_name_len = strlen (nl->var_name) + 1;
|
||||
obj_name = get_mem (obj_name_len+1);
|
||||
- strcpy (obj_name, nl->var_name);
|
||||
- strcat (obj_name, "%");
|
||||
+ strlcpy (obj_name, nl->var_name, obj_name_len+1);
|
||||
+ strlcat (obj_name, "%", obj_name_len+1);
|
||||
|
||||
/* Now loop over the components. Update the component pointer
|
||||
with the return value from nml_write_obj. This loop jumps
|
||||
@@ -2108,11 +2108,11 @@ get_name:
|
||||
|
||||
if (component_flag)
|
||||
{
|
||||
- ext_name = (char*)get_mem (strlen (root_nl->var_name)
|
||||
- + (saved_string ? strlen (saved_string) : 0)
|
||||
- + 1);
|
||||
- strcpy (ext_name, root_nl->var_name);
|
||||
- strcat (ext_name, saved_string);
|
||||
+ index_type ext_name_len = strlen (root_nl->var_name) +
|
||||
+ (saved_string ? strlen (saved_string) : 0) + 1;
|
||||
+ ext_name = (char*)get_mem (ext_name_len);
|
||||
+ strlcpy (ext_name, root_nl->var_name, ext_name_len);
|
||||
+ strlcat (ext_name, saved_string, ext_name_len);
|
||||
nl = find_nml_node (ext_name);
|
||||
free_mem (ext_name);
|
||||
}
|
12
lang/gcc/4.0/patches/patch-libgfortran_io_open_c
Normal file
12
lang/gcc/4.0/patches/patch-libgfortran_io_open_c
Normal file
@ -0,0 +1,12 @@
|
||||
$OpenBSD: patch-libgfortran_io_open_c,v 1.1 2005/06/16 18:04:41 espie Exp $
|
||||
--- libgfortran/io/open.c.orig Thu Jun 16 19:33:08 2005
|
||||
+++ libgfortran/io/open.c Thu Jun 16 19:35:41 2005
|
||||
@@ -316,7 +316,7 @@ new_unit (unit_flags * flags)
|
||||
break;
|
||||
|
||||
ioparm.file = tmpname;
|
||||
- ioparm.file_len = sprintf(ioparm.file, "fort.%d", ioparm.unit);
|
||||
+ ioparm.file_len = snprintf(ioparm.file, sizeof tmpname, "fort.%d", ioparm.unit);
|
||||
break;
|
||||
|
||||
default:
|
12
lang/gcc/4.0/patches/patch-libgfortran_io_read_c
Normal file
12
lang/gcc/4.0/patches/patch-libgfortran_io_read_c
Normal file
@ -0,0 +1,12 @@
|
||||
$OpenBSD: patch-libgfortran_io_read_c,v 1.1 2005/06/16 18:04:41 espie Exp $
|
||||
--- libgfortran/io/read.c.orig Thu Jun 16 19:36:47 2005
|
||||
+++ libgfortran/io/read.c Thu Jun 16 19:38:52 2005
|
||||
@@ -704,7 +704,7 @@ read_f (fnode * f, char *dest, int lengt
|
||||
digits++;
|
||||
}
|
||||
*(p++) = 'e';
|
||||
- sprintf (p, "%d", exponent);
|
||||
+ snprintf (p, (p-buffer)+i, "%d", exponent);
|
||||
|
||||
/* Do the actual conversion. */
|
||||
convert_real (dest, buffer, length);
|
12
lang/gcc/4.0/patches/patch-libgfortran_io_transfer_c
Normal file
12
lang/gcc/4.0/patches/patch-libgfortran_io_transfer_c
Normal file
@ -0,0 +1,12 @@
|
||||
$OpenBSD: patch-libgfortran_io_transfer_c,v 1.1 2005/06/16 18:04:41 espie Exp $
|
||||
--- libgfortran/io/transfer.c.orig Thu Jun 16 13:12:11 2005
|
||||
+++ libgfortran/io/transfer.c Thu Jun 16 13:12:50 2005
|
||||
@@ -1633,7 +1633,7 @@ st_set_nml_var (void * var_addr, char *
|
||||
nml->mem_pos = var_addr;
|
||||
|
||||
nml->var_name = (char*) get_mem (strlen (var_name) + 1);
|
||||
- strcpy (nml->var_name, var_name);
|
||||
+ strlcpy (nml->var_name, var_name, strlen (var_name) + 1);
|
||||
|
||||
nml->len = (int) len;
|
||||
nml->string_length = (index_type) string_length;
|
64
lang/gcc/4.0/patches/patch-libgfortran_io_write_c
Normal file
64
lang/gcc/4.0/patches/patch-libgfortran_io_write_c
Normal file
@ -0,0 +1,64 @@
|
||||
$OpenBSD: patch-libgfortran_io_write_c,v 1.1 2005/06/16 18:04:41 espie Exp $
|
||||
--- libgfortran/io/write.c.orig Thu Jun 16 13:12:55 2005
|
||||
+++ libgfortran/io/write.c Thu Jun 16 19:36:34 2005
|
||||
@@ -346,7 +346,7 @@ output_float (fnode *f, double value, in
|
||||
ndigits = 27 - edigits;
|
||||
}
|
||||
|
||||
- sprintf (buffer, "%+-#31.*e", ndigits - 1, value);
|
||||
+ snprintf (buffer, 32, "%+-#31.*e", ndigits - 1, value);
|
||||
|
||||
/* Check the resulting string has punctuation in the correct places. */
|
||||
if (buffer[2] != '.' || buffer[ndigits + 2] != 'e')
|
||||
@@ -1344,6 +1344,7 @@ nml_write_obj (namelist_info * obj, inde
|
||||
index_type clen;
|
||||
index_type elem_ctr;
|
||||
index_type obj_name_len;
|
||||
+ index_type ext_name_len;
|
||||
void * p ;
|
||||
char cup;
|
||||
char * obj_name;
|
||||
@@ -1476,33 +1477,34 @@ nml_write_obj (namelist_info * obj, inde
|
||||
components. */
|
||||
|
||||
/* First ext_name => get length of all possible components */
|
||||
-
|
||||
- ext_name = (char*)get_mem ( (base_name ? strlen (base_name) : 0)
|
||||
+ ext_name_len = (base_name ? strlen (base_name) : 0)
|
||||
+ (base ? strlen (base->var_name) : 0)
|
||||
+ strlen (obj->var_name)
|
||||
+ obj->var_rank * NML_DIGITS
|
||||
- + 1);
|
||||
+ + 1;
|
||||
|
||||
- strcpy(ext_name, base_name ? base_name : "");
|
||||
+ ext_name = (char*)get_mem ( ext_name_len );
|
||||
+
|
||||
+ strlcpy(ext_name, base_name ? base_name : "", ext_name_len);
|
||||
clen = base ? strlen (base->var_name) : 0;
|
||||
- strcat (ext_name, obj->var_name + clen);
|
||||
+ strlcat (ext_name, obj->var_name + clen, ext_name_len);
|
||||
|
||||
/* Append the qualifier. */
|
||||
|
||||
for (dim_i = 0; dim_i < obj->var_rank; dim_i++)
|
||||
{
|
||||
- strcat (ext_name, dim_i ? "" : "(");
|
||||
+ strlcat (ext_name, dim_i ? "" : "(", ext_name_len);
|
||||
clen = strlen (ext_name);
|
||||
st_sprintf (ext_name + clen, "%d", obj->ls[dim_i].idx);
|
||||
- strcat (ext_name, (dim_i == obj->var_rank - 1) ? ")" : ",");
|
||||
+ strlcat (ext_name, (dim_i == obj->var_rank - 1) ? ")" : ",", ext_name_len);
|
||||
}
|
||||
|
||||
/* Now obj_name. */
|
||||
|
||||
obj_name_len = strlen (obj->var_name) + 1;
|
||||
obj_name = get_mem (obj_name_len+1);
|
||||
- strcpy (obj_name, obj->var_name);
|
||||
- strcat (obj_name, "%");
|
||||
+ strlcpy (obj_name, obj->var_name, obj_name_len + 1);
|
||||
+ strlcat (obj_name, "%" , obj_name_len + 1);
|
||||
|
||||
/* Now loop over the components. Update the component pointer
|
||||
with the return value from nml_write_obj => this loop jumps
|
14
lang/gcc/4.0/patches/patch-libgfortran_runtime_environ_c
Normal file
14
lang/gcc/4.0/patches/patch-libgfortran_runtime_environ_c
Normal file
@ -0,0 +1,14 @@
|
||||
$OpenBSD: patch-libgfortran_runtime_environ_c,v 1.1 2005/06/16 18:04:41 espie Exp $
|
||||
--- libgfortran/runtime/environ.c.orig Thu Jun 16 19:32:41 2005
|
||||
+++ libgfortran/runtime/environ.c Thu Jun 16 19:32:59 2005
|
||||
@@ -557,8 +557,8 @@ check_buffered (int n)
|
||||
if (options.all_unbuffered)
|
||||
return 0;
|
||||
|
||||
- strcpy (name, "GFORTRAN_UNBUFFERED_");
|
||||
- strcat (name, gfc_itoa (n));
|
||||
+ strlcpy (name, "GFORTRAN_UNBUFFERED_", 40);
|
||||
+ strlcat (name, gfc_itoa (n), 40);
|
||||
|
||||
v.name = name;
|
||||
v.value = 2;
|
Loading…
Reference in New Issue
Block a user