From: Ilya Zakharevich Date: Tue, 13 Oct 1998 04:46:00 +0000 (-0400) Subject: Memory overrun in os2.c X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6756f2f0bba8a181bed0219554fd4fa332538853;p=p5sagit%2Fp5-mst-13.2.git Memory overrun in os2.c Message-Id: <199810130846.EAA00769@monk.mps.ohio-state.edu> p4raw-id: //depot/perl@1996 --- diff --git a/os2/Makefile.SHs b/os2/Makefile.SHs index aaeed53..8fd7bfb 100644 --- a/os2/Makefile.SHs +++ b/os2/Makefile.SHs @@ -18,7 +18,7 @@ $spitshell >>Makefile <= sizeof scrbuf) { + Safefree(scr); + longbuf: + croak("Size of scriptname too big: %d", l); + } + strcpy(scrbuf, scr); + Safefree(scr); + scr = scrbuf; if (scr) { FILE *file = fopen(scr, "r"); @@ -555,7 +565,6 @@ char *inicmd; if (!file) goto panic_file; if (!fgets(buf, sizeof buf, file)) { /* Empty... */ - int l = strlen(scr); buf[0] = 0; fclose(file); @@ -564,18 +573,18 @@ char *inicmd; documentation, DosQueryAppType sometimes (?) does not append ".exe", so we could have reached this place). */ - if (l + 5 < 512) { /* size of buffer in find_script */ - strcpy(scr + l, ".exe"); - if (PerlLIO_stat(scr,&PL_statbuf) >= 0 + if (l + 5 < sizeof scrbuf) { + strcpy(scrbuf + l, ".exe"); + if (PerlLIO_stat(scrbuf,&PL_statbuf) >= 0 && !S_ISDIR(PL_statbuf.st_mode)) { /* Found */ tmps = scr; pass++; goto reread; - } else { - scr[l] = 0; - } - } + } else + scrbuf[l] = 0; + } else + goto longbuf; } if (fclose(file) != 0) { /* Failure */ panic_file: