diff --git a/inc/dskdefs.h b/inc/dskdefs.h index f5cfa94c..6e6ed25b 100644 --- a/inc/dskdefs.h +++ b/inc/dskdefs.h @@ -19,6 +19,8 @@ LispPTR COM_writepage(LispPTR *args); LispPTR COM_truncatefile(LispPTR *args); LispPTR COM_changedir(LispPTR *args); LispPTR COM_getfreeblock(LispPTR *args); +void conc_dir_and_name(char *dir, char *name, char *fname, size_t fname_size); +void conc_name_and_version(char *name, char *ver, char *rname, size_t rname_size); void separate_version(char *name, char *ver, int checkp); int unpack_filename(char *file, char *dir, char *name, char *ver, int checkp); int true_name(char *path); diff --git a/inc/locfile.h b/inc/locfile.h index 856c23d6..58d7fc59 100644 --- a/inc/locfile.h +++ b/inc/locfile.h @@ -410,90 +410,6 @@ do { \ } \ } while (0) -/* - * Name: ConcDirAndName - * - * Argument: char *dir The name of the directory. - * char *name The name of a file. - * char *fname The place where the full file name should be - * stored. - * Value: N/A - * - * Side Effect: fname is replaced with the full file name. - * - * Description: - * - * Concatenate the directory name and root file name. Checks if dir contains - * the trail directory delimiter or not. - * - */ - -#define ConcDirAndName(dir, name, fname) do { \ - \ - char *lf_cp1, *lf_cp2; \ - \ - lf_cp1 = dir; \ - lf_cp2 = dir; \ - \ - while (*lf_cp2 != '\0') { \ - switch (*lf_cp2) { \ - \ - case '/': \ - lf_cp1 = lf_cp2; \ - lf_cp2++; \ - break; \ - \ - default: \ - lf_cp2++; \ - break; \ - } \ - } \ - if (lf_cp1 == (lf_cp2 - 1)) { \ - if (lf_cp1 == (dir)) { \ - /* dir is a root directory. */ \ - strcpy(fname, "/"); \ - strcat(fname, name); \ - } else { \ - /* The trail directory is included. */ \ - strcpy(fname, dir); \ - strcat(fname, name); \ - } \ - } else { \ - /* The trail directory is not included */ \ - strcpy(fname, dir); \ - strcat(fname, "/"); \ - strcat(fname, name); \ - } \ - } while (0) - -/* - * Name: ConcNameAndVersion - * - * Argument: char *name The root file name. - * char *ver The file version. - * char *rname The place where the concatenated file name will be - * stored. - * Value: N/A - * - * Side Effect: rname is replaced with the concatenated file name. - * - * Description: - * - * Concatenate the root file name and its version in UNIX format. - * - */ - -#define ConcNameAndVersion(name, ver, rname) do { \ - if (*(ver) != '\0') { \ - strcpy(rname, name); \ - strcat(rname, ".~"); \ - strcat(rname, ver); \ - strcat(rname, "~"); \ - } else { \ - strcpy(rname, name); \ - } \ -} while (0) - #define VERSIONLEN 16 #define MAXVERSION 999999999 diff --git a/src/dsk.c b/src/dsk.c index a96a0f43..f5e94713 100644 --- a/src/dsk.c +++ b/src/dsk.c @@ -27,7 +27,7 @@ #include "car-cdrdefs.h" // for cdr, car #include "dskdefs.h" // for COM_changedir, COM_closefile, COM_getfile... #include "lispemul.h" // for NIL, LispPTR, ATOM_T -#include "locfile.h" // for ConcDirAndName, LASTVERSIONARRAY, ConcNam... +#include "locfile.h" // for LASTVERSIONARRAY #include "lspglob.h" #include "lsptypes.h" #include "timeout.h" // for TIMEOUT, ERRSETJMP, S_TOUT, TIMEOUT0 @@ -84,7 +84,6 @@ static int get_oldest(char *dir, FileName *varray, char *afile, char *vfile); static int get_new(char *dir, FileName *varray, char *afile, char *vfile); static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile); static int get_version_array(char *dir, char *file); - #ifdef DOS static void separate_drive(char *lfname, char *drive) { @@ -376,7 +375,7 @@ LispPTR COM_openfile(LispPTR *args) if (unpack_filename(file, dir, name, ver, 1) == 0) return (NIL); if (true_name(dir) != -1) return (0); if (get_version_array(dir, name) == 0) return (NIL); - ConcNameAndVersion(name, ver, file); + conc_name_and_version(name, ver, file, sizeof(file)); switch (args[1]) { case RECOG_OLD: @@ -878,8 +877,8 @@ LispPTR DSK_getfilename(LispPTR *args) * The file name is specified with a trail directory delimiter. * We should recognize it as a directory. */ - strcpy(aname, dir); - strcpy(vname, dir); + strlcpy(aname, dir, sizeof(aname)); + strlcpy(vname, dir, sizeof(vname)); dirp = 1; } else { /* @@ -888,7 +887,7 @@ LispPTR DSK_getfilename(LispPTR *args) */ if (get_version_array(dir, name) == 0) return (NIL); - ConcNameAndVersion(name, ver, aname); + conc_name_and_version(name, ver, aname, sizeof(aname)); if (get_old(dir, VA.files, aname, vname) == 0) return (NIL); if ((rval = true_name(aname)) == 0) return (NIL); @@ -896,11 +895,11 @@ LispPTR DSK_getfilename(LispPTR *args) /* * The specified file is a directory file. */ - strcpy(vname, aname); + strlcpy(vname, aname, sizeof(vname)); dirp = 1; } else { #ifdef DOS - strcpy(vname, aname); + strlcpy(vname, aname, sizeof(vname)); #endif dirp = 0; } @@ -922,13 +921,13 @@ LispPTR DSK_getfilename(LispPTR *args) * The file name is specified with a trail directory delimiter. * We should recognize it as a directory. */ - strcpy(aname, dir); - strcpy(vname, dir); + strlcpy(aname, dir, sizeof(aname)); + strlcpy(vname, dir, sizeof(vname)); dirp = 1; } else { if (get_version_array(dir, name) == 0) return (NIL); - ConcNameAndVersion(name, ver, aname); + conc_name_and_version(name, ver, aname, sizeof(aname)); if (get_oldest(dir, VA.files, aname, vname) == 0) return (NIL); if ((rval = true_name(aname)) == 0) return (NIL); @@ -936,11 +935,11 @@ LispPTR DSK_getfilename(LispPTR *args) /* * The specified file is a directory file. */ - strcpy(vname, aname); + strlcpy(vname, aname, sizeof(vname)); dirp = 1; } else { #ifdef DOS - strcpy(vname, aname); + strlcpy(vname, aname, sizeof(vname)); #endif dirp = 0; } @@ -955,20 +954,20 @@ LispPTR DSK_getfilename(LispPTR *args) * as if, the subsequent OPENFILE will find the truth. */ if (true_name(dir) != -1) { - strcpy(vname, file); + strlcpy(vname, file, sizeof(vname)); dirp = 0; } else if (strcmp(name, "") == 0) { /* * The file name is specified with a trail directory delimiter. * We should recognize it as a directory. */ - strcpy(aname, dir); - strcpy(vname, dir); + strlcpy(aname, dir, sizeof(aname)); + strlcpy(vname, dir, sizeof(vname)); dirp = 1; } else { - ConcDirAndName(dir, name, aname); + conc_dir_and_name(dir, name, aname, sizeof(aname)); if ((rval = true_name(aname)) == -1) { - strcpy(vname, aname); + strlcpy(vname, aname, sizeof(vname)); dirp = 1; } else { /* @@ -977,7 +976,7 @@ LispPTR DSK_getfilename(LispPTR *args) */ if (get_version_array(dir, name) == 0) return (NIL); - ConcNameAndVersion(name, ver, aname); + conc_name_and_version(name, ver, aname, sizeof(aname)); if (get_new(dir, VA.files, aname, vname) == 0) return (NIL); dirp = 0; } @@ -993,17 +992,17 @@ LispPTR DSK_getfilename(LispPTR *args) * fails, we try "new" recognition. */ if (true_name(dir) != -1) { - strcpy(vname, file); + strlcpy(vname, file, sizeof(vname)); dirp = 0; } else { - ConcDirAndName(dir, name, aname); + conc_dir_and_name(dir, name, aname, sizeof(aname)); if ((rval = true_name(aname)) == -1) { - strcpy(vname, aname); + strlcpy(vname, aname, sizeof(vname)); dirp = 1; } else { if (get_version_array(dir, name) == 0) return (NIL); - ConcNameAndVersion(name, ver, aname); + conc_name_and_version(name, ver, aname, sizeof(aname)); if (get_old_new(dir, VA.files, aname, vname) == 0) return (NIL); dirp = 0; } @@ -1019,10 +1018,10 @@ LispPTR DSK_getfilename(LispPTR *args) * directories. The file name itself is recognized as if. */ if (true_name(dir) != -1) return (NIL); - ConcDirAndName(dir, name, vname); - strcpy(aname, vname); + conc_dir_and_name(dir, name, vname, sizeof(vname)); + strlcpy(aname, vname, sizeof(aname)); if (true_name(aname) == -1) { - strcpy(vname, aname); + strlcpy(vname, aname, sizeof(vname)); dirp = 1; } else { dirp = 0; @@ -1057,8 +1056,8 @@ LispPTR DSK_getfilename(LispPTR *args) { char dver[VERSIONLEN]; separate_version(vname, dver, 0); - ConcDirAndName(dir, name, aname); - ConcNameAndVersion(aname, dver, vname); + conc_dir_and_name(dir, name, aname, sizeof(aname)); + conc_name_and_version(aname, dver, vname, sizeof(vname)); } #endif /* DOS */ @@ -1143,7 +1142,7 @@ LispPTR DSK_deletefile(LispPTR *args) * of it. */ - ConcNameAndVersion(fbuf, ver, file); + conc_name_and_version(fbuf, ver, file, sizeof(file)); if (get_oldest(dir, VA.files, file, fbuf) == 0) return (NIL); if (get_versionless(VA.files, vless, dir) == 0) { @@ -1295,7 +1294,7 @@ LispPTR DSK_renamefile(LispPTR *args) /* * We maintain the destination to handle the link damaged case correctly. */ - ConcDirAndName(dir, fbuf, dst); + conc_dir_and_name(dir, fbuf, dst, sizeof(dst)); if (maintain_version(dst, 0) == 0) return (NIL); if (get_version_array(dir, fbuf) == 0) return (NIL); @@ -1306,7 +1305,7 @@ LispPTR DSK_renamefile(LispPTR *args) * of it. */ - ConcNameAndVersion(fbuf, ver, dst); + conc_name_and_version(fbuf, ver, dst, sizeof(dst)); if (get_new(dir, VA.files, dst, fbuf) == 0) return (NIL); /* @@ -1321,7 +1320,7 @@ LispPTR DSK_renamefile(LispPTR *args) if (OnlyVersionlessP(VA.files)) { get_versionless(VA.files, vless, dir); if (strcmp(dst, vless) != 0) { - ConcNameAndVersion(vless, "1", fbuf); + conc_name_and_version(vless, "1", fbuf, sizeof(fbuf)); TIMEOUT(rval = rename(vless, fbuf)); if (rval == -1) { *Lisp_errno = errno; @@ -1361,7 +1360,7 @@ LispPTR DSK_renamefile(LispPTR *args) * code, we have to recognize it again to know the "real" accessible name * of it. */ - ConcNameAndVersion(fbuf, ver, src); + conc_name_and_version(fbuf, ver, src, sizeof(src)); if (get_old(dir, VA.files, src, fbuf) == 0) return (NIL); if (get_versionless(VA.files, vless, dir) == 0) { @@ -1401,7 +1400,7 @@ LispPTR DSK_renamefile(LispPTR *args) } else { need_maintain_flg = 0; } - strcpy(svless, vless); + strlcpy(svless, vless, sizeof(svless)); } /* @@ -1620,10 +1619,10 @@ LispPTR COM_getfileinfo(LispPTR *args) /* * The directory is specified. */ - strcpy(file, dir); + strlcpy(file, dir, sizeof(file)); } else { if (get_version_array(dir, name) == 0) return (NIL); - ConcNameAndVersion(name, ver, file); + conc_name_and_version(name, ver, file, sizeof(file)); if (get_old(dir, VA.files, file, name) == 0) return (NIL); } } @@ -1812,7 +1811,7 @@ LispPTR COM_setfileinfo(LispPTR *args) if (unpack_filename(file, dir, name, ver, 1) == 0) return (NIL); if (true_name(dir) != -1) return (0); if (get_version_array(dir, name) == 0) return (NIL); - ConcNameAndVersion(name, ver, file); + conc_name_and_version(name, ver, file, sizeof(file)); if (get_old(dir, VA.files, file, name) == 0) return (NIL); } @@ -2362,16 +2361,16 @@ void separate_version(char *name, char *ver, int checkp) */ ver_no = strtoul(start + 1, (char **)NULL, 10); sprintf(ver_buf, "%u", ver_no); - strcpy(ver, ver_buf); + strlcpy(ver, ver_buf, sizeof(ver)); return; } else { *(start - 1) = '\0'; - strcpy(ver, ver_buf); + strlcpy(ver, ver_buf, sizeof(ver)); return; } } } else if (strchr(name, '%')) { - strcpy(ver, "0"); + strlcpy(ver, "0", sizeof(ver)); return; } NO: @@ -2430,7 +2429,7 @@ int unpack_filename(char *file, char *dir, char *name, char *ver, int checkp) *dir = '\0'; } - strcpy(name, cp + 1); + strlcpy(name, cp + 1, sizeof(name)); separate_version(name, ver, checkp); return (1); } @@ -2520,10 +2519,96 @@ int true_name(char *path) * to dir by locate_file. */ } - strcpy(path, dir); + strlcpy(path, dir, sizeof(path)); return (type); } +/* + * Name: conc_dir_and_name + * + * Argument: char *dir The name of the directory. + * char *name The name of a file. + * char *fname The place where the full file name should be + * stored. + * Value: N/A + * + * Side Effect: fname is replaced with the full file name. + * + * Description: + * + * Concatenate the directory name and root file name. Checks if dir contains + * the trail directory delimiter or not. + * + */ + +void conc_dir_and_name(char *dir, char *name, char *fname, size_t fname_size) +{ + char *lf_cp1, *lf_cp2; + + lf_cp1 = dir; + lf_cp2 = dir; + + while (*lf_cp2 != '\0') { + switch (*lf_cp2) { + + case '/': + lf_cp1 = lf_cp2; + lf_cp2++; + break; + + default: + lf_cp2++; + break; + } + } + if (lf_cp1 == (lf_cp2 - 1)) { + if (lf_cp1 == (dir)) { + /* dir is a root directory. */ + strlcpy(fname, "/", fname_size); + strlcat(fname, name, fname_size); + } else { + /* The trail directory is included. */ + strlcpy(fname, dir, fname_size); + strlcat(fname, name, fname_size); + } + } else { + /* The trail directory is not included */ + strlcpy(fname, dir, fname_size); + strlcat(fname, "/", fname_size); + strlcat(fname, name, fname_size); + } +} + +/* + * Name: conc_name_and_version + * + * Argument: char *name The root file name. + * char *ver The file version. + * char *rname The place where the concatenated file name will be + * stored. + * size_t rname_size The size of the storage allocated for rname + * Value: N/A + * + * Side Effect: rname is replaced with the concatenated file name. + * + * Description: + * + * Concatenate the root file name and its version in UNIX format. + * + */ + +void conc_name_and_version(char *name, char *ver, char *rname, size_t rname_size) +{ + if (*ver != '\0') { + strlcpy(rname, name, rname_size); + strlcat(rname, ".~", rname_size); + strlcat(rname, ver, rname_size); + strlcat(rname, "~", rname_size); + } else { + strlcpy(rname, name, rname_size); + } +} + /* * Name: locate_file * @@ -2558,7 +2643,7 @@ static int locate_file(char *dir, char *name) sprintf(path, "%s\\%s", dir, name); DIR_OR_FILE_P(path, type); if (type != 0) { - strcpy(dir, path); + strlcpy(dir, path, sizeof(dir)); return (type); } @@ -2577,17 +2662,17 @@ static int locate_file(char *dir, char *name) sprintf(path, "%s/%s", dir, name); DIR_OR_FILE_P(path, type); if (type != 0) { - strcpy(dir, path); + strlcpy(dir, path, sizeof(dir)); return (type); } /* Next try with all lower case name. */ - strcpy(nb1, name); + strlcpy(nb1, name, sizeof(nb1)); DOWNCASE(nb1); sprintf(path, "%s/%s", dir, nb1); DIR_OR_FILE_P(path, type); if (type != 0) { - strcpy(dir, path); + strlcpy(dir, path, sizeof(dir)); return (type); } @@ -2596,7 +2681,7 @@ static int locate_file(char *dir, char *name) sprintf(path, "%s/%s", dir, nb1); DIR_OR_FILE_P(path, type); if (type != 0) { - strcpy(dir, path); + strlcpy(dir, path, sizeof(dir)); return (type); } @@ -2612,13 +2697,13 @@ static int locate_file(char *dir, char *name) errno = 0, S_TOUT(dp = readdir(dirp))) if (dp) { if (strlen(dp->d_name) == len) { - strcpy(nb2, dp->d_name); + strlcpy(nb2, dp->d_name, sizeof(nb2)); UPCASE(nb2); if (strcmp(nb1, nb2) == 0) { sprintf(path, "%s/%s", dir, dp->d_name); DIR_OR_FILE_P(path, type); if (type != 0) { - strcpy(dir, path); + strlcpy(dir, path, sizeof(dir)); TIMEOUT(closedir(dirp)); return (type); } @@ -2695,7 +2780,7 @@ static int make_directory(char *dir) return (0); } if (*cp == '\0') { - strcpy(dir, dir_buf); + strlcpy(dir, dir_buf, sizeof(dir)); return (1); } *dp++ = DIRSEP; @@ -2705,7 +2790,7 @@ static int make_directory(char *dir) case -1: /* Directory */ if (*cp == '\0') { /* Every subdirectories are examined. */ - strcpy(dir, dir_buf); + strlcpy(dir, dir_buf, sizeof(dir)); return (1); } else { dp = dir_buf; @@ -2933,7 +3018,7 @@ static int get_version_array(char *dir, char *file) isslash = 1; if (!isslash) - strcpy(lcased_file, dir); /* Only add the dir if it's real */ + strlcpy(lcased_file, dir, sizeof(lcased_file)); /* Only add the dir if it's real */ else if (drive) { lcased_file[0] = drive; lcased_file[1] = DRIVESEP; @@ -2941,9 +3026,9 @@ static int get_version_array(char *dir, char *file) } else *lcased_file = '\0'; - /* strcpy(lcased_file, dir); removed when above code added 3/4/93 */ - strcat(lcased_file, DIRSEPSTR); - strcat(lcased_file, file); + /* strlcpy(lcased_file, dir, sizeof(lcased_file)); removed when above code added 3/4/93 */ + strlcat(lcased_file, DIRSEPSTR, sizeof(lcased_file)); + strlcat(lcased_file, file, sizeof(lcased_file)); separate_version(lcased_file, ver, 1); DOWNCASE(lcased_file); @@ -2957,8 +3042,8 @@ static int get_version_array(char *dir, char *file) TIMEOUT(res = _dos_findfirst(old_file, _A_NORMAL | _A_SUBDIR, &dirp)); if (res == 0) { - strcpy(name, dirp.name); - strcpy(VA.files[varray_index].name, name); + strlcpy(name, dirp.name, sizeof(name)); + strlcpy(VA.files[varray_index].name, name, sizeof(VA.files[0].name)); VA.files[varray_index].version_no = 0; varray_index++; } @@ -2975,11 +3060,11 @@ static int get_version_array(char *dir, char *file) } */ for (; res == 0; S_TOUT(res = _dos_findnext(&dirp))) { - strcpy(name, dirp.name); + strlcpy(name, dirp.name, sizeof(name)); separate_version(name, ver, 1); DOWNCASE(name); - strcpy(VA.files[varray_index].name, dirp.name); + strlcpy(VA.files[varray_index].name, dirp.name, sizeof(VA.files[0].name)); if (*ver == '\0') { /* Versionless file */ VA.files[varray_index].version_no = 1; @@ -3015,9 +3100,9 @@ static int get_version_array(char *dir, char *file) * untouched by the sort, which is intentional. */ if (!NoFileP(VA.files)) { - strcpy(name, VA.files[0].name); + strlcpy(name, VA.files[0].name, sizeof(name)); separate_version(name, ver, 1); - strcpy(VA.files[varray_index].name, name); + strlcpy(VA.files[varray_index].name, name, sizeof(VA.files[0].name)); if (varray_index > 1) { qsort(VA.files, varray_index, sizeof(*VA.files), compare_file_versions); } @@ -3040,7 +3125,7 @@ static int get_version_array(char *dir, char *file) * First of all, prepare a lower cased file name for the case insensitive * search. Also we have to separate file name from its version field. */ - strcpy(lcased_file, file); + strlcpy(lcased_file, file, sizeof(lcased_file)); separate_version(lcased_file, ver, 1); DOWNCASE(lcased_file); @@ -3064,7 +3149,7 @@ static int get_version_array(char *dir, char *file) } else { VA.dir_ino = sbuf.st_ino; VA.lastMTime = sbuf.st_mtim; - strcpy(VA.name, lcased_file); + strlcpy(VA.name, lcased_file, sizeof(VA.name)); } errno = 0; @@ -3083,14 +3168,14 @@ static int get_version_array(char *dir, char *file) for (S_TOUT(dp = readdir(dirp)); dp != NULL || errno == EINTR; errno = 0, S_TOUT(dp = readdir(dirp))) if (dp) { - strcpy(name, dp->d_name); + strlcpy(name, dp->d_name, sizeof(name)); separate_version(name, ver, 1); DOWNCASE(name); if (strcmp(name, lcased_file) == 0) { /* * This file can be regarded as a same file in Lisp sense. */ - strcpy(VA.files[varray_index].name, dp->d_name); + strlcpy(VA.files[varray_index].name, dp->d_name, sizeof(VA.files[0].name)); if (*ver == '\0') { /* Versionless file */ VA.files[varray_index].version_no = 0; @@ -3126,9 +3211,9 @@ static int get_version_array(char *dir, char *file) * untouched by the sort, which is intentional. */ if (!NoFileP(VA.files)) { - strcpy(name, VA.files[0].name); + strlcpy(name, VA.files[0].name, sizeof(name)); separate_version(name, ver, 1); - strcpy(VA.files[varray_index].name, name); + strlcpy(VA.files[varray_index].name, name, sizeof(VA.files[0].name)); if (varray_index > 1) { qsort(VA.files, varray_index, sizeof(*VA.files), compare_file_versions); } @@ -3196,7 +3281,7 @@ static int maintain_version(char *file, int forcep) */ #ifndef DOS get_versionless(VA.files, vless, dir); - ConcNameAndVersion(vless, "1", fname); + conc_name_and_version(vless, "1", fname, sizeof(fname)); TIMEOUT(rval = link(vless, fname)); if (rval == -1) { *Lisp_errno = errno; @@ -3219,15 +3304,15 @@ static int maintain_version(char *file, int forcep) * to the existing highest versioned file. */ FindHighestVersion(VA.files, entry, max_no); - ConcDirAndName(dir, entry->name, old_file); + conc_dir_and_name(dir, entry->name, old_file, sizeof(old_file)); /* * The versionless file should have the same case name as the old * file. */ #ifndef DOS - strcpy(fname, entry->name); + strlcpy(fname, entry->name, sizeof(fname)); separate_version(fname, ver, 1); - ConcDirAndName(dir, fname, vless); + conc_dir_and_name(dir, fname, vless, sizeof(vless)); TIMEOUT(rval = link(old_file, vless)); if (rval == -1) { *Lisp_errno = errno; @@ -3252,7 +3337,7 @@ static int maintain_version(char *file, int forcep) * file. */ #ifndef DOS - ConcNameAndVersion(vless, ver, old_file); + conc_name_and_version(vless, ver, old_file, sizeof(old_file)); TIMEOUT(rval = link(vless, old_file)); if (rval == -1) { *Lisp_errno = errno; @@ -3281,15 +3366,15 @@ static int maintain_version(char *file, int forcep) return (0); } FindHighestVersion(VA.files, entry, max_no); - ConcDirAndName(dir, entry->name, old_file); + conc_dir_and_name(dir, entry->name, old_file, sizeof(old_file)); /* * The versionless file should have the same case name as the old * file. */ #ifndef DOS - strcpy(fname, entry->name); + strlcpy(fname, entry->name, sizeof(fname)); separate_version(fname, ver, 1); - ConcDirAndName(dir, fname, vless); + conc_dir_and_name(dir, fname, vless, sizeof(vless)); TIMEOUT(rval = link(old_file, vless)); if (rval == -1) { *Lisp_errno = errno; @@ -3332,7 +3417,7 @@ static int get_versionless(FileName *varray, char *file, char *dir) while (varray->version_no != LASTVERSIONARRAY) { if (varray->version_no == 0) { - ConcDirAndName(dir, varray->name, file); + conc_dir_and_name(dir, varray->name, file, sizeof(file)); return (1); } else varray++; @@ -3411,7 +3496,7 @@ static int check_vless_link(char *vless, FileName *varray, char *to_file, int *h max_entry = varray; } if (!found && varray->version_no != 0) { - ConcDirAndName(dir, varray->name, name); + conc_dir_and_name(dir, varray->name, name, sizeof(name)); TIMEOUT(rval = stat(name, &sbuf)); if (rval != 0) { *Lisp_errno = errno; @@ -3431,7 +3516,7 @@ static int check_vless_link(char *vless, FileName *varray, char *to_file, int *h } else { *highest_p = 0; } - strcpy(to_file, name); + strlcpy(to_file, name, sizeof(to_file)); } else { *to_file = '\0'; } @@ -3489,7 +3574,7 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile) /* "Old" file have to be existing, thus varray should not be empty. */ if (NoFileP(varray)) return (0); - strcpy(name, afile); + strlcpy(name, afile, sizeof(name)); separate_version(name, ver, 1); if (get_versionless(varray, vless, dir) == 0) { @@ -3503,8 +3588,8 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile) * is an old file. */ FindHighestVersion(varray, entry, max_no); - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } else { /* @@ -3515,8 +3600,8 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile) ver_no = strtoul(ver, (char **)NULL, 10); FindSpecifiedVersion(varray, entry, ver_no); if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } else return (0); @@ -3532,8 +3617,8 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile) * No version is specified. The versionless file is dealt * with as version 1. */ - ConcNameAndVersion(vless, "1", vfile); - strcpy(afile, vless); + conc_name_and_version(vless, "1", vfile, sizeof(vfile)); + strlcpy(afile, vless, sizeof(afile)); return (1); } else { ver_no = strtoul(ver, (char **)NULL, 10); @@ -3542,9 +3627,9 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile) * Version 1 is specified. The versionless file is * dealt with as a version 1 file. */ - ConcNameAndVersion(name, "1", afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vless); + conc_name_and_version(name, "1", afile, sizeof(afile)); + conc_dir_and_name(dir, afile, vfile, sizeof(vfile)); + strlcpy(afile, vless, sizeof(afile)); return (1); } else { /* @@ -3571,8 +3656,8 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile) */ FindHighestVersion(varray, entry, max_no); sprintf(vbuf, "%u", max_no + 1); - ConcNameAndVersion(vless, vbuf, vfile); - strcpy(afile, vless); + conc_name_and_version(vless, vbuf, vfile, sizeof(vfile)); + strlcpy(afile, vless, sizeof(afile)); return (1); } else { /* A version is specified. */ @@ -3586,8 +3671,8 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile) * missing versionless file. */ sprintf(vbuf, "%u", ver_no); - ConcNameAndVersion(vless, vbuf, vfile); - strcpy(afile, vless); + conc_name_and_version(vless, vbuf, vfile, sizeof(vfile)); + strlcpy(afile, vless, sizeof(afile)); return (1); } else { /* @@ -3596,8 +3681,8 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile) */ FindSpecifiedVersion(varray, entry, ver_no); if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } else return (0); @@ -3615,8 +3700,8 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile) * in varray is an old file. */ FindHighestVersion(varray, entry, max_no); - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } else { /* @@ -3627,8 +3712,8 @@ static int get_old(char *dir, FileName *varray, char *afile, char *vfile) ver_no = strtoul(ver, (char **)NULL, 10); FindSpecifiedVersion(varray, entry, ver_no); if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } else return (0); @@ -3688,7 +3773,7 @@ static int get_oldest(char *dir, FileName *varray, char *afile, char *vfile) /* "Oldest" file have to be existing, thus varray should not be empty. */ if (NoFileP(varray)) return (0); - strcpy(name, afile); + strlcpy(name, afile, sizeof(name)); separate_version(name, ver, 1); if (get_versionless(varray, vless, dir) == 0) { @@ -3702,8 +3787,8 @@ static int get_oldest(char *dir, FileName *varray, char *afile, char *vfile) * is an oldest file. */ FindLowestVersion(varray, entry, min_no); - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } else { /* @@ -3714,8 +3799,8 @@ static int get_oldest(char *dir, FileName *varray, char *afile, char *vfile) ver_no = strtoul(ver, (char **)NULL, 10); FindSpecifiedVersion(varray, entry, ver_no); if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } else return (0); @@ -3731,8 +3816,8 @@ static int get_oldest(char *dir, FileName *varray, char *afile, char *vfile) * No version is specified. The versionless file is dealt * with as version 1. */ - ConcNameAndVersion(vless, "1", vfile); - strcpy(afile, vless); + conc_name_and_version(vless, "1", vfile, sizeof(vfile)); + strlcpy(afile, vless, sizeof(afile)); return (1); } else { ver_no = strtoul(ver, (char **)NULL, 10); @@ -3741,9 +3826,9 @@ static int get_oldest(char *dir, FileName *varray, char *afile, char *vfile) * Version 1 is specified. The versionless file is * dealt with as a version 1 file. */ - ConcNameAndVersion(name, "1", afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vless); + conc_name_and_version(name, "1", afile, sizeof(afile)); + conc_dir_and_name(dir, afile, vfile, sizeof(vfile)); + strlcpy(afile, vless, sizeof(afile)); return (1); } else { /* @@ -3767,8 +3852,8 @@ static int get_oldest(char *dir, FileName *varray, char *afile, char *vfile) * dealt with as the oldest version. */ FindLowestVersion(varray, entry, min_no); - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } else { /* A version is specified. */ @@ -3782,8 +3867,8 @@ static int get_oldest(char *dir, FileName *varray, char *afile, char *vfile) * missing versionless file. */ sprintf(vbuf, "%u", ver_no); - ConcNameAndVersion(vless, vbuf, vfile); - strcpy(afile, vless); + conc_name_and_version(vless, vbuf, vfile, sizeof(vfile)); + strlcpy(afile, vless, sizeof(afile)); return (1); } else { /* @@ -3792,8 +3877,8 @@ static int get_oldest(char *dir, FileName *varray, char *afile, char *vfile) */ FindSpecifiedVersion(varray, entry, ver_no); if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } else return (0); @@ -3811,8 +3896,8 @@ static int get_oldest(char *dir, FileName *varray, char *afile, char *vfile) * in varray is an old file. */ FindLowestVersion(varray, entry, min_no); - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } else { /* @@ -3823,8 +3908,8 @@ static int get_oldest(char *dir, FileName *varray, char *afile, char *vfile) ver_no = strtoul(ver, (char **)NULL, 10); FindSpecifiedVersion(varray, entry, ver_no); if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } else return (0); @@ -3882,7 +3967,7 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile) int highest_p; FileName *entry; - strcpy(name, afile); + strlcpy(name, afile, sizeof(name)); separate_version(name, ver, 1); #ifndef DOS @@ -3898,9 +3983,9 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile) * If version is not specified or 1 is specified, * we can return versionless file as afile. */ - ConcNameAndVersion(name, "1", afile); - ConcDirAndName(dir, afile, vfile); - ConcDirAndName(dir, name, afile); + conc_name_and_version(name, "1", afile, sizeof(afile)); + conc_dir_and_name(dir, afile, vfile, sizeof(vfile)); + conc_dir_and_name(dir, name, afile, sizeof(afile)); return (1); } #ifndef DOS @@ -3909,8 +3994,8 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile) * A version other than 1 is specified. "New" file * is recognized as if. */ - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); + conc_dir_and_name(dir, afile, vfile, sizeof(vfile)); + strlcpy(afile, vfile, sizeof(afile)); return (1); } } @@ -3932,11 +4017,11 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile) * versioned file as the name of the new file, so that * new file is as the same case as old. */ - strcpy(name, entry->name); + strlcpy(name, entry->name, sizeof(name)); separate_version(name, ver, 1); - ConcDirAndName(dir, name, afile); - ConcNameAndVersion(afile, vbuf, vfile); - strcpy(afile, vfile); + conc_dir_and_name(dir, name, afile, sizeof(afile)); + conc_name_and_version(afile, vbuf, vfile, sizeof(vfile)); + strlcpy(afile, vfile, sizeof(afile)); return (1); } else { /* @@ -3947,8 +4032,8 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile) ver_no = strtoul(ver, (char **)NULL, 10); FindSpecifiedVersion(varray, entry, ver_no); if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } /* @@ -3962,9 +4047,9 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile) * files has the name in same case. */ while (varray->version_no != LASTVERSIONARRAY) varray++; - ConcNameAndVersion(varray->name, ver, afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); + conc_name_and_version(varray->name, ver, afile, sizeof(afile)); + conc_dir_and_name(dir, afile, vfile, sizeof(vfile)); + strlcpy(afile, vfile, sizeof(afile)); return (1); } } else if (OnlyVersionlessP(varray)) { @@ -3978,8 +4063,8 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile) * No version is specified. The versionless file is dealt * with as version 1. Thus new version is 2. */ - ConcNameAndVersion(vless, "2", vfile); - strcpy(afile, vfile); + conc_name_and_version(vless, "2", vfile, sizeof(vfile)); + strlcpy(afile, vfile, sizeof(afile)); return (1); } else { ver_no = strtoul(ver, (char **)NULL, 10); @@ -3988,16 +4073,16 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile) * Version 1 is specified. The versionless file is * dealt with as a version 1 file. */ - ConcNameAndVersion(name, "1", afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vless); + conc_name_and_version(name, "1", afile, sizeof(afile)); + conc_dir_and_name(dir, afile, vfile, sizeof(vfile)); + strlcpy(afile, vless, sizeof(afile)); return (1); } else { /* * Other versions than 1 are recognized as if. */ - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); + conc_dir_and_name(dir, afile, vfile, sizeof(vfile)); + strlcpy(afile, vfile, sizeof(afile)); return (1); } } @@ -4019,8 +4104,8 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile) */ FindHighestVersion(varray, entry, max_no); sprintf(vbuf, "%u", max_no + 2); - ConcNameAndVersion(vless, vbuf, vfile); - strcpy(afile, vfile); + conc_name_and_version(vless, vbuf, vfile, sizeof(vfile)); + strlcpy(afile, vfile, sizeof(afile)); return (1); } else { /* A version is specified. */ @@ -4034,8 +4119,8 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile) * missing versionless file. */ sprintf(vbuf, "%u", ver_no); - ConcNameAndVersion(vless, vbuf, vfile); - strcpy(afile, vless); + conc_name_and_version(vless, vbuf, vfile, sizeof(vfile)); + strlcpy(afile, vless, sizeof(afile)); return (1); } else { /* @@ -4044,8 +4129,8 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile) */ FindSpecifiedVersion(varray, entry, ver_no); if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } /* @@ -4062,9 +4147,9 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile) * case. */ while (varray->version_no != LASTVERSIONARRAY) varray++; - ConcNameAndVersion(varray->name, ver, afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); + conc_name_and_version(varray->name, ver, afile, sizeof(afile)); + conc_dir_and_name(dir, afile, vfile, sizeof(vfile)); + strlcpy(afile, vfile, sizeof(afile)); return (1); } } @@ -4086,11 +4171,11 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile) * We will use the name of the highest versioned file * as the name of the new file. */ - strcpy(vless, entry->name); + strlcpy(vless, entry->name, sizeof(vless)); separate_version(vless, ver, 1); - ConcDirAndName(dir, vless, afile); - ConcNameAndVersion(afile, vbuf, vfile); - strcpy(afile, vfile); + conc_dir_and_name(dir, vless, afile, sizeof(afile)); + conc_name_and_version(afile, vbuf, vfile, sizeof(vfile)); + strlcpy(afile, vfile, sizeof(afile)); return (1); } else { /* @@ -4101,8 +4186,8 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile) ver_no = strtoul(ver, (char **)NULL, 10); FindSpecifiedVersion(varray, entry, ver_no); if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } /* @@ -4115,11 +4200,11 @@ static int get_new(char *dir, FileName *varray, char *afile, char *vfile) * new file. */ FindHighestVersion(varray, entry, max_no); - strcpy(vless, entry->name); + strlcpy(vless, entry->name, sizeof(vless)); separate_version(vless, vbuf, 1); - ConcDirAndName(dir, vless, afile); - ConcNameAndVersion(afile, ver, vfile); - strcpy(afile, vfile); + conc_dir_and_name(dir, vless, afile, sizeof(afile)); + conc_name_and_version(afile, ver, vfile, sizeof(vfile)); + strlcpy(afile, vfile, sizeof(afile)); return (1); } } @@ -4176,7 +4261,7 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile) int highest_p; FileName *entry; - strcpy(name, afile); + strlcpy(name, afile, sizeof(name)); separate_version(name, ver, 1); if (NoFileP(varray)) { @@ -4189,17 +4274,17 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile) * If version is not specified or 1 is specified, * we can return versionless file as afile. */ - ConcNameAndVersion(name, "1", afile); - ConcDirAndName(dir, afile, vfile); - ConcDirAndName(dir, name, afile); + conc_name_and_version(name, "1", afile, sizeof(afile)); + conc_dir_and_name(dir, afile, vfile, sizeof(vfile)); + conc_dir_and_name(dir, name, afile, sizeof(afile)); return (1); } else { /* * A version other than 1 is specified. "New" file * is recognized as if. */ - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); + conc_dir_and_name(dir, afile, vfile, sizeof(vfile)); + strlcpy(afile, vfile, sizeof(afile)); return (1); } } @@ -4215,8 +4300,8 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile) * is an old file. */ FindHighestVersion(varray, entry, max_no); - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } else { /* @@ -4227,8 +4312,8 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile) ver_no = strtoul(ver, (char **)NULL, 10); FindSpecifiedVersion(varray, entry, ver_no); if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } /* @@ -4242,9 +4327,9 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile) * files has the name in same case. */ while (varray->version_no != LASTVERSIONARRAY) varray++; - ConcNameAndVersion(varray->name, ver, afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); + conc_name_and_version(varray->name, ver, afile, sizeof(afile)); + conc_dir_and_name(dir, afile, vfile, sizeof(vfile)); + strlcpy(afile, vfile, sizeof(afile)); return (1); } } else if (OnlyVersionlessP(varray)) { @@ -4258,8 +4343,8 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile) * No version is specified. The versionless file is dealt * with as version 1. */ - ConcNameAndVersion(vless, "1", vfile); - strcpy(afile, vless); + conc_name_and_version(vless, "1", vfile, sizeof(vfile)); + strlcpy(afile, vless, sizeof(afile)); return (1); } else { ver_no = strtoul(ver, (char **)NULL, 10); @@ -4268,16 +4353,16 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile) * Version 1 is specified. The versionless file is * dealt with as a version 1 file. */ - ConcNameAndVersion(name, "1", afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vless); + conc_name_and_version(name, "1", afile, sizeof(afile)); + conc_dir_and_name(dir, afile, vfile, sizeof(vfile)); + strlcpy(afile, vless, sizeof(afile)); return (1); } else { /* * Other versions than 1 are recognized as if. */ - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); + conc_dir_and_name(dir, afile, vfile, sizeof(vfile)); + strlcpy(afile, vfile, sizeof(afile)); return (1); } } @@ -4298,8 +4383,8 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile) */ FindHighestVersion(varray, entry, max_no); sprintf(vbuf, "%u", max_no + 1); - ConcNameAndVersion(vless, vbuf, vfile); - strcpy(afile, vless); + conc_name_and_version(vless, vbuf, vfile, sizeof(vfile)); + strlcpy(afile, vless, sizeof(afile)); return (1); } else { /* A version is specified. */ @@ -4313,8 +4398,8 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile) * missing versionless file. */ sprintf(vbuf, "%u", ver_no); - ConcNameAndVersion(vless, vbuf, vfile); - strcpy(afile, vless); + conc_name_and_version(vless, vbuf, vfile, sizeof(vfile)); + strlcpy(afile, vless, sizeof(afile)); return (1); } else { /* @@ -4323,8 +4408,8 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile) */ FindSpecifiedVersion(varray, entry, ver_no); if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } /* @@ -4341,9 +4426,9 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile) * case. */ while (varray->version_no != LASTVERSIONARRAY) varray++; - ConcNameAndVersion(varray->name, ver, afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); + conc_name_and_version(varray->name, ver, afile, sizeof(afile)); + conc_dir_and_name(dir, afile, vfile, sizeof(vfile)); + strlcpy(afile, vfile, sizeof(afile)); return (1); } } @@ -4359,8 +4444,8 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile) * in varray is an old file. */ FindHighestVersion(varray, entry, max_no); - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } else { /* @@ -4371,8 +4456,8 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile) ver_no = strtoul(ver, (char **)NULL, 10); FindSpecifiedVersion(varray, entry, ver_no); if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); + conc_dir_and_name(dir, entry->name, afile, sizeof(afile)); + strlcpy(vfile, afile, sizeof(vfile)); return (1); } /* @@ -4385,11 +4470,11 @@ static int get_old_new(char *dir, FileName *varray, char *afile, char *vfile) * new file. */ FindHighestVersion(varray, entry, max_no); - strcpy(vless, entry->name); + strlcpy(vless, entry->name, sizeof(vless)); separate_version(vless, vbuf, 1); - ConcDirAndName(dir, vless, afile); - ConcNameAndVersion(afile, ver, vfile); - strcpy(afile, vfile); + conc_dir_and_name(dir, vless, afile, sizeof(afile)); + conc_name_and_version(afile, ver, vfile, sizeof(vfile)); + strlcpy(afile, vfile, sizeof(afile)); return (1); } } diff --git a/src/ufs.c b/src/ufs.c index b5173cd4..e50f6e47 100644 --- a/src/ufs.c +++ b/src/ufs.c @@ -829,7 +829,7 @@ int unixpathname(char *src, char *dst, int versionp, int genp) else *ver2 = '\0'; #endif /* DOS */ - ConcNameAndVersion(fbuf2, ver2, dst); + conc_name_and_version(fbuf2, ver2, dst, MAXPATHLEN); } return (1); } @@ -1087,7 +1087,7 @@ int lisppathname(char *fullname, char *lispname, int dirp, int versionp) *cp = '\0'; } if (versionp && *ver != '\0') { - ConcNameAndVersion(fbuf, ver, namebuf); + conc_name_and_version(fbuf, ver, namebuf, MAXPATHLEN); } else { strcpy(namebuf, fbuf); } @@ -1186,7 +1186,7 @@ int quote_fname(char *file) *cp = '\0'; } if (*ver != '\0') { - ConcNameAndVersion(fbuf, ver, namebuf); + conc_name_and_version(fbuf, ver, namebuf, sizeof(namebuf)); } else { strcpy(namebuf, fbuf); }