Commit 9ffe483f by Richard Kenner

(expand_lib, main): Fix off-by-one bugs in several calls to malloc.

From-SVN: r8344
parent 684e4e06
...@@ -116,7 +116,7 @@ expand_lib (name) ...@@ -116,7 +116,7 @@ expand_lib (name)
{ {
char *lib, *lib_path; char *lib, *lib_path;
lib = malloc (strlen (name) + 5); lib = malloc (strlen (name) + 6);
strcpy (lib, "lib"); strcpy (lib, "lib");
strcat (lib, name); strcat (lib, name);
strcat (lib, ".a"); strcat (lib, ".a");
...@@ -195,7 +195,7 @@ main (argc, argv) ...@@ -195,7 +195,7 @@ main (argc, argv)
int out_len; int out_len;
i++; i++;
out_len = strlen (argv[i]) + 9; out_len = strlen (argv[i]) + 10;
buff = malloc (out_len); buff = malloc (out_len);
strcpy (buff, "-out:"); strcpy (buff, "-out:");
strcat (buff, argv[i]); strcat (buff, argv[i]);
...@@ -213,7 +213,7 @@ main (argc, argv) ...@@ -213,7 +213,7 @@ main (argc, argv)
new_len = strlen (&argv[i][2]); new_len = strlen (&argv[i][2]);
search_dirs_len = strlen (search_dirs); search_dirs_len = strlen (search_dirs);
nbuff = malloc (new_len); nbuff = malloc (new_len + 1);
strcpy (nbuff, &argv[i][2]); strcpy (nbuff, &argv[i][2]);
for (j = 0; j < new_len; j++) for (j = 0; j < new_len; j++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment