Subject: Crunchgen bug and patch
To: None <tech-userlevel@netbsd.org>
From: None <hypnosses@pulltheplug.org>
List: tech-userlevel
Date: 06/10/2006 12:28:18
There is a small bug in crunchgen when dealing with a large string which
causes it to crash. heres a patch for it.




Index: crunchgen.c
===================================================================
RCS file: /cvsroot/src/usr.bin/crunch/crunchgen/crunchgen.c,v
retrieving revision 1.69
diff -r1.69 crunchgen.c
163,166c163,166
<       case 'm':       strcpy(outmkname, optarg); break;
<       case 'c':       strcpy(outcfname, optarg); break;
<       case 'e':       strcpy(execfname, optarg); break;
<       case 'd':       strcpy(dbg, optarg); break;
---
>       case 'm':       strlcpy(outmkname, optarg, sizeof outmkname); break;
>       case 'c':       strlcpy(outcfname, optarg, sizeof outcfname); break;
>       case 'e':       strlcpy(execfname, optarg, sizeof execfname); break;
>       case 'd':       strlcpy(dbg, optarg, sizeof dbg); break;
168,169c168,169
<       case 'D':       strcpy(topdir, optarg); break;
<       case 'L':       strcpy(libdir, optarg); break;
---
>       case 'D':       strlcpy(topdir, optarg, sizeof topdir); break;
>       case 'L':       strlcpy(libdir, optarg, sizeof libdir); break;
187c187
<     strcpy(infilename, argv[0]);
---
>     strlcpy(infilename, argv[0], sizeof infilename);
193c193
<       strcpy(confname, p + 1);
---
>       strlcpy(confname, p + 1, sizeof confname);
195c195
<       strcpy(confname, infilename);
---
>       strlcpy(confname, infilename, sizeof confname);
272c272
<     strcpy(curfilename, filename);
---
>     strlcpy(curfilename, filename, sizeof curfilename);
349c349
<               strcpy(tmppath, argv[i]);
---
>               strlcpy(tmppath, argv[i], sizeof tmppath);
352c352
<                   strcpy(tmppath, curdir);
---
>                   strlcpy(tmppath, curdir, sizeof tmppath);
354c354
<                   strcpy(tmppath, topdir);
---
>                   strlcpy(tmppath, topdir, sizeof tmppath);
469c469
<               strcpy(tmppath, curdir);
---
>               strlcpy(tmppath, curdir, sizeof tmppath);
471c471
<               strcpy(tmppath, topdir);
---
>               strlcpy(tmppath, topdir, sizeof tmppath);
602c602
<                       strcpy(tmppath, curdir);
---
>                       strlcpy(tmppath, curdir, sizeof tmppath);
604c604
<                       strcpy(tmppath, topdir);
---
>                       strlcpy(tmppath, topdir, sizeof tmppath);