|
14 | 14 | #include <stdio.h> // for NULL, sprintf, size_t, rename, SEEK_SET |
15 | 15 | #include <stddef.h> // for ptrdiff_t |
16 | 16 | #include <stdlib.h> // for strtoul, qsort |
17 | | -#include <string.h> // for strcpy, strcmp, strlen, strncpy, strchr |
| 17 | +#include <string.h> // for strlcpy, strcmp, strlen, strncpy, strchr |
18 | 18 | #include <sys/stat.h> // for stat, fstat, mkdir, S_ISREG, st_atime, chmod |
19 | 19 | #include <sys/types.h> // for ino_t, time_t, off_t |
20 | 20 | #include <unistd.h> // for unlink, close, link, lseek, access, chdir |
@@ -264,9 +264,9 @@ LispPTR COM_openfile(LispPTR *args) |
264 | 264 | * convert a version field. |
265 | 265 | */ |
266 | 266 | #ifdef DOS |
267 | | - unixpathname(lfname, file, dskp, 0, drive, &extlen, rawname); |
| 267 | + unixpathname(lfname, file, sizeof(file), dskp, 0, drive, &extlen, rawname); |
268 | 268 | #else |
269 | | - unixpathname(lfname, file, dskp, 0); |
| 269 | + unixpathname(lfname, file, sizeof(file), dskp, 0); |
270 | 270 | #endif |
271 | 271 |
|
272 | 272 | /* |
@@ -598,8 +598,7 @@ LispPTR COM_closefile(LispPTR *args) |
598 | 598 | * Convert a Lisp file name to UNIX one. If host is DSK, we also have to |
599 | 599 | * convert a version field. |
600 | 600 | */ |
601 | | - dskp ? unixpathname(lfname, file, 1, 0, drive, &extlen, rawname) |
602 | | - : unixpathname(lfname, file, 0, 0, drive, &extlen, rawname); |
| 601 | + unixpathname(lfname, file, sizeof(file), dskp, drive, &extlen, rawname); |
603 | 602 | fd = LispNumToCInt(args[1]); |
604 | 603 | cdate = (time_t)LispNumToCInt(args[2]); |
605 | 604 | if (!dskp) { |
@@ -721,8 +720,7 @@ LispPTR COM_closefile(LispPTR *args) |
721 | 720 | * Convert a Lisp file name to UNIX one. If host is DSK, we also have to |
722 | 721 | * convert a version field. |
723 | 722 | */ |
724 | | - dskp ? unixpathname(lfname, file, 1, 0) : unixpathname(lfname, file, 0, 0); |
725 | | - |
| 723 | + unixpathname(lfname, file, sizeof(file), dskp, 0); |
726 | 724 | fd = LispNumToCInt(args[1]); |
727 | 725 | cdate = (time_t)LispNumToCInt(args[2]); |
728 | 726 |
|
@@ -849,9 +847,9 @@ LispPTR DSK_getfilename(LispPTR *args) |
849 | 847 | * unixpathname specifies it. |
850 | 848 | */ |
851 | 849 | #ifdef DOS |
852 | | - if (unixpathname(lfname, file, 1, 0, drive, &extlen, rawname) == 0) return (NIL); |
| 850 | + if (unixpathname(lfname, file, sizeof(file), 1, 0, drive, &extlen, rawname) == 0) return (NIL); |
853 | 851 | #else |
854 | | - if (unixpathname(lfname, file, 1, 0) == 0) return (NIL); |
| 852 | + if (unixpathname(lfname, file, sizeof(file), 1, 0) == 0) return (NIL); |
855 | 853 | #endif |
856 | 854 |
|
857 | 855 | if (unpack_filename(file, dir, name, ver, 1) == 0) return (NIL); |
@@ -1120,9 +1118,9 @@ LispPTR DSK_deletefile(LispPTR *args) |
1120 | 1118 | LispStringToCString(args[0], fbuf, MAXPATHLEN); |
1121 | 1119 | #ifdef DOS |
1122 | 1120 | separate_drive(fbuf, drive); |
1123 | | - unixpathname(fbuf, file, 1, 0, drive, &extlen, rawname); |
| 1121 | + unixpathname(fbuf, file, sizeof(file), 1, 0, drive, &extlen, rawname); |
1124 | 1122 | #else |
1125 | | - unixpathname(fbuf, file, 1, 0); |
| 1123 | + unixpathname(fbuf, file, sizeof(file), 1, 0); |
1126 | 1124 | #endif |
1127 | 1125 |
|
1128 | 1126 | if (unpack_filename(file, dir, fbuf, ver, 1) == 0) return (NIL); |
@@ -1271,17 +1269,17 @@ LispPTR DSK_renamefile(LispPTR *args) |
1271 | 1269 | LispStringToCString(args[0], fbuf, MAXPATHLEN); |
1272 | 1270 | #ifdef DOS |
1273 | 1271 | separate_drive(fbuf, drive1); |
1274 | | - unixpathname(fbuf, src, 1, 0, drive1, &extlen1, rawname1); |
| 1272 | + unixpathname(fbuf, src, sizeof(src), 1, 0, drive1, &extlen1, rawname1); |
1275 | 1273 | #else /* DOS */ |
1276 | | - unixpathname(fbuf, src, 1, 0); |
| 1274 | + unixpathname(fbuf, src, sizeof(src), 1, 0); |
1277 | 1275 | #endif /* DOS */ |
1278 | 1276 |
|
1279 | 1277 | LispStringToCString(args[1], fbuf, MAXPATHLEN); |
1280 | 1278 | #ifdef DOS |
1281 | 1279 | separate_drive(fbuf, drive2); |
1282 | | - unixpathname(fbuf, dst, 1, 0, drive2, &extlen2, rawname2); |
| 1280 | + unixpathname(fbuf, dst, sizeof(dst), 1, 0, drive2, &extlen2, rawname2); |
1283 | 1281 | #else /* DOS */ |
1284 | | - unixpathname(fbuf, dst, 1, 0); |
| 1282 | + unixpathname(fbuf, dst, sizeof(dst), 1, 0); |
1285 | 1283 | #endif /* DOS */ |
1286 | 1284 |
|
1287 | 1285 | if (unpack_filename(dst, dir, fbuf, ver, 1) == 0) return (NIL); |
@@ -1492,9 +1490,9 @@ LispPTR DSK_directorynamep(LispPTR *args) |
1492 | 1490 | /* Convert Xerox Lisp file naming convention to Unix one. */ |
1493 | 1491 | #ifdef DOS |
1494 | 1492 | separate_drive(dirname, drive); |
1495 | | - if (unixpathname(dirname, fullname, 1, 0, drive, 0, 0) == 0) return (NIL); |
| 1493 | + if (unixpathname(dirname, fullname, sizeof(fullname), 1, 0, drive, 0, 0) == 0) return (NIL); |
1496 | 1494 | #else /* DOS*/ |
1497 | | - if (unixpathname(dirname, fullname, 1, 0) == 0) return (NIL); |
| 1495 | + if (unixpathname(dirname, fullname, sizeof(fullname), 1, 0) == 0) return (NIL); |
1498 | 1496 | #endif /* DOS */ |
1499 | 1497 |
|
1500 | 1498 | if (true_name(fullname) != -1) return (NIL); |
@@ -1599,9 +1597,9 @@ LispPTR COM_getfileinfo(LispPTR *args) |
1599 | 1597 | * convert a version field. |
1600 | 1598 | */ |
1601 | 1599 | #ifdef DOS |
1602 | | - unixpathname(lfname, file, dskp, 0, drive, &extlen, rawname); |
| 1600 | + unixpathname(lfname, file, sizeof(file), dskp, 0, drive, &extlen, rawname); |
1603 | 1601 | #else /* DOS */ |
1604 | | - unixpathname(lfname, file, dskp, 0); |
| 1602 | + unixpathname(lfname, file, sizeof(file), dskp, 0); |
1605 | 1603 | #endif /* DOS */ |
1606 | 1604 |
|
1607 | 1605 | /* |
@@ -1794,9 +1792,9 @@ LispPTR COM_setfileinfo(LispPTR *args) |
1794 | 1792 | * convert a version field. |
1795 | 1793 | */ |
1796 | 1794 | #ifdef DOS |
1797 | | - unixpathname(lfname, file, dskp, 0, drive, &extlen, rawname); |
| 1795 | + unixpathname(lfname, file, sizeof(file), dskp, 0, drive, &extlen, rawname); |
1798 | 1796 | #else /* DOS */ |
1799 | | - unixpathname(lfname, file, dskp, 0); |
| 1797 | + unixpathname(lfname, file, sizeof(file), dskp, 0); |
1800 | 1798 | #endif /* DOS */ |
1801 | 1799 |
|
1802 | 1800 | /* |
@@ -2141,9 +2139,9 @@ LispPTR COM_changedir(LispPTR *args) |
2141 | 2139 | return (NIL); |
2142 | 2140 |
|
2143 | 2141 | #ifdef DOS |
2144 | | - if (!unixpathname(lfname, dir, 0, 0, drive, 0, 0)) return (NIL); |
| 2142 | + if (!unixpathname(lfname, dir, sizeof(dir), 0, 0, drive, 0, 0)) return (NIL); |
2145 | 2143 | #else /* DOS */ |
2146 | | - if (!unixpathname(lfname, dir, 0, 0)) return (NIL); |
| 2144 | + if (!unixpathname(lfname, dir, sizeof(dir), 0, 0)) return (NIL); |
2147 | 2145 | #endif /* DOS */ |
2148 | 2146 |
|
2149 | 2147 | if (dskp) { |
@@ -2241,9 +2239,9 @@ LispPTR COM_getfreeblock(LispPTR *args) |
2241 | 2239 | return (NIL); |
2242 | 2240 |
|
2243 | 2241 | #ifdef DOS |
2244 | | - if (!unixpathname(lfname, file, 0, 0, drive, 0, 0)) return (NIL); |
| 2242 | + if (!unixpathname(lfname, file, sizeof(file), 0, 0, drive, 0, 0)) return (NIL); |
2245 | 2243 | #else /* DOS */ |
2246 | | - if (!unixpathname(lfname, file, 0, 0)) return (NIL); |
| 2244 | + if (!unixpathname(lfname, file, sizeof(file), 0, 0)) return (NIL); |
2247 | 2245 | #endif /* DOS */ |
2248 | 2246 |
|
2249 | 2247 | if (!unpack_filename(file, dir, name, ver, 0)) return (NIL); |
|
0 commit comments