/* fullname is the MAX_PATH+1 sized buffer returned from PerlDir_mapA()\r
* or the 2*MAX_PATH sized local buffer in the __CYGWIN__ case.\r
*/\r
- strcpy(lastchar+1, "\\");\r
+ if (lastchar - fullname < MAX_PATH - 1)\r
+ strcpy(lastchar+1, "\\");\r
}\r
}\r
\r
WCHAR wide_path[MAX_PATH+1];\r
WCHAR *long_path;\r
\r
- wcscpy(wide_path, wstr);\r
- Safefree(wstr);\r
- long_path = my_longpathW(wide_path);\r
- if (long_path) {\r
- ST(0) = wstr_to_sv(aTHX_ long_path);\r
- XSRETURN(1);\r
+ if (wcslen(wstr) < countof(wide_path)) {\r
+ wcscpy(wide_path, wstr);\r
+ long_path = my_longpathW(wide_path);\r
+ if (long_path) {\r
+ ST(0) = wstr_to_sv(aTHX_ long_path);\r
+ XSRETURN(1);\r
+ }\r
}\r
+ Safefree(wstr);\r
}\r
else {\r
SV *path;\r
\r
path = ST(0);\r
pathstr = SvPV(path,len);\r
- strcpy(tmpbuf, pathstr);\r
- pathstr = my_longpathA(tmpbuf);\r
- if (pathstr) {\r
- ST(0) = sv_2mortal(newSVpvn(pathstr, strlen(pathstr)));\r
- XSRETURN(1);\r
+ if (len < sizeof(tmpbuf)) {\r
+ strcpy(tmpbuf, pathstr);\r
+ pathstr = my_longpathA(tmpbuf);\r
+ if (pathstr) {\r
+ ST(0) = sv_2mortal(newSVpvn(pathstr, strlen(pathstr)));\r
+ XSRETURN(1);\r
+ }\r
}\r
}\r
XSRETURN_EMPTY;\r
{\r
dXSARGS;\r
BOOL bResult;\r
+ char *pszSourceFile;\r
char szSourceFile[MAX_PATH+1];\r
\r
if (items != 3)\r
Perl_croak(aTHX_ "usage: Win32::CopyFile($from, $to, $overwrite)");\r
- strcpy(szSourceFile, PerlDir_mapA(SvPV_nolen(ST(0))));\r
- bResult = CopyFileA(szSourceFile, PerlDir_mapA(SvPV_nolen(ST(1))), !SvTRUE(ST(2)));\r
- if (bResult)\r
- XSRETURN_YES;\r
+\r
+ pszSourceFile = PerlDir_mapA(SvPV_nolen(ST(0)));\r
+ if (strlen(pszSourceFile) < sizeof(szSourceFile)) {\r
+ strcpy(szSourceFile, pszSourceFile);\r
+ bResult = CopyFileA(szSourceFile, PerlDir_mapA(SvPV_nolen(ST(1))), !SvTRUE(ST(2)));\r
+ if (bResult)\r
+ XSRETURN_YES;\r
+ }\r
XSRETURN_NO;\r
}\r
\r