openbsd-ports/devel/gputils/patches/patch-gplink_gplink_c

85 lines
3.2 KiB
Plaintext

$OpenBSD: patch-gplink_gplink_c,v 1.2 2004/01/30 01:01:11 naddy Exp $
--- gplink/gplink.c.orig 2004-01-17 13:33:51.000000000 +1100
+++ gplink/gplink.c 2004-01-25 20:51:41.000000000 +1100
@@ -265,7 +265,7 @@ void gplink_open_coff(char *name)
FILE *coff;
char file_name[BUFSIZ];
- strcpy(file_name, name);
+ strlcpy(file_name, name, sizeof(file_name));
coff = fopen(file_name, "rb");
if ((coff == NULL) && (strchr(file_name, PATH_CHAR) == 0)) {
@@ -273,9 +273,9 @@ void gplink_open_coff(char *name)
int i;
for(i = 0; i < state.numpaths; i++) {
- strcpy(file_name, state.paths[i]);
- strcat(file_name, COPY_CHAR);
- strcat(file_name, name);
+ strlcpy(file_name, state.paths[i], sizeof(file_name));
+ strlcat(file_name, COPY_CHAR, sizeof(file_name));
+ strlcat(file_name, name, sizeof(file_name));
coff = fopen(file_name, "rb");
if (coff != NULL) {
break;
@@ -387,7 +387,7 @@ int main(int argc, char *argv[])
gp_init();
/* initialize */
- gp_date_string(state.startdate);
+ gp_date_string(state.startdate, sizeof(state.startdate));
state.hex_format = inhx32;
state.numpaths = 0;
state.byte_addr = 0;
@@ -457,7 +457,7 @@ int main(int argc, char *argv[])
state.mapfile = normal;
break;
case 'o':
- strcpy(state.basefilename, optarg);
+ strlcpy(state.basefilename, optarg, sizeof(state.basefilename));
pc = strrchr(state.basefilename, '.');
if (pc)
*pc = 0;
@@ -489,7 +489,7 @@ int main(int argc, char *argv[])
if(state.basefilename[0] == '\0') {
/* set default output filename to be a.o, a.hex, a.cod, a.map */
- strcpy(state.basefilename, "a");
+ strlcpy(state.basefilename, "a", sizeof(state.basefilename));
}
/* Add the library path to the include paths list last, so that the user
@@ -499,12 +499,12 @@ int main(int argc, char *argv[])
}
/* setup output filenames */
- strcpy(state.hexfilename, state.basefilename);
- strcat(state.hexfilename, ".hex");
- strcpy(state.mapfilename, state.basefilename);
- strcat(state.mapfilename, ".map");
- strcpy(state.objfilename, state.basefilename);
- strcat(state.objfilename, ".cof");
+ strlcpy(state.hexfilename, state.basefilename, sizeof(state.hexfilename));
+ strlcat(state.hexfilename, ".hex", sizeof(state.hexfilename));
+ strlcpy(state.mapfilename, state.basefilename, sizeof(state.mapfilename));
+ strlcat(state.mapfilename, ".map", sizeof(state.mapfilename));
+ strlcpy(state.objfilename, state.basefilename, sizeof(state.objfilename));
+ strlcat(state.objfilename, ".cof", sizeof(state.objfilename));
/* Open all objects and archives in the file list. */
for ( ; optind < argc; optind++) {
@@ -528,9 +528,9 @@ int main(int argc, char *argv[])
gp_error("linker script not specified and can't determine default script");
return EXIT_FAILURE;
}
- strcpy(file_name, gp_lkr_path);
- strcat(file_name, COPY_CHAR);
- strcat(file_name, script_name);
+ strlcpy(file_name, gp_lkr_path, sizeof(file_name));
+ strlcat(file_name, COPY_CHAR, sizeof(file_name));
+ strlcat(file_name, script_name, sizeof(file_name));
gp_message("using default linker script \"%s\"", file_name);
open_src(file_name, 0);
yyparse();