-/* $OpenBSD: dired.c,v 1.94 2021/02/24 13:58:46 lum Exp $ */
+/* $OpenBSD: dired.c,v 1.95 2021/02/26 01:17:21 lum Exp $ */
/* This file is in the public domain. */
topath = adjustname(toname, TRUE);
}
}
+ if (topath == NULL)
+ return (FALSE);
if (strcmp(frname, topath) == 0) {
ewprintf("Cannot copy to same file: %s", frname);
return (TRUE);
off = strlcpy(toname, curbp->b_fname, sizeof(toname));
if (off >= sizeof(toname) - 1) { /* can't happen, really */
dobeep();
- ewprintf("Directory name too long");
+ ewprintf("Name too long");
return (FALSE);
}
(void)xbasename(sname, frname, NFILEN);
topath = adjustname(toname, TRUE);
if (stat(topath, &statbuf) == 0) {
if (S_ISDIR(statbuf.st_mode)) {
- off = snprintf(toname, sizeof(toname), "%s/%s",
+ ret = snprintf(toname, sizeof(toname), "%s/%s",
topath, sname);
- if (off < 0 || off >= sizeof(toname) - 1) {
+ if (ret < 0 || ret >= sizeof(toname) - 1) {
dobeep();
ewprintf("Directory name too long");
return (FALSE);
topath = adjustname(toname, TRUE);
}
}
+ if (topath == NULL)
+ return (FALSE);
if (strcmp(frname, topath) == 0) {
ewprintf("Cannot move to same file: %s", frname);
return (TRUE);