summaryrefslogtreecommitdiff
path: root/usr.bin/mg/fileio.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-02-27 05:49:15 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-02-27 05:49:15 +0000
commita6f71e3ec90a208acfacca77a9eca8869cd2700d (patch)
tree027f8c751895ff77f9453d580699b66f4354e8e8 /usr.bin/mg/fileio.c
parentce97acbbd054d08bb0bd7accaeac8026af6bb3dd (diff)
We don't have silly SYSV 14-character file name limits. Taken from
the BSD fileio.c. Note that this module is rife with PATH_MAX overflow possibilities.
Diffstat (limited to 'usr.bin/mg/fileio.c')
-rw-r--r--usr.bin/mg/fileio.c26
1 files changed, 3 insertions, 23 deletions
diff --git a/usr.bin/mg/fileio.c b/usr.bin/mg/fileio.c
index e2fa01f40fb..6c42a013a27 100644
--- a/usr.bin/mg/fileio.c
+++ b/usr.bin/mg/fileio.c
@@ -144,29 +144,8 @@ fbackupfile(fn) char *fn; {
return (ABORT);
}
(void) strcpy(nname, fn);
-/*
- * with BSD, just strcat the ~. But SV has a max file name of 14, so
- * we have to check.
- */
- lastpart = strrchr(nname, '/');
- if (lastpart)
- lastpart++;
- else
- lastpart = nname;
- i = strlen(lastpart);
- if (i > 13)
- if (lastpart[13] == '~') { /* already a backup name */
- free(nname);
- return(FALSE);
- }
- else
- lastpart[13] = '~';
- else {
- lastpart[i] = '~';
- lastpart[i+1] = 0;
- }
- (void) unlink(nname); /* Ignore errors. */
- if (link(fn, nname) != 0 || unlink(fn) != 0) {
+ (void) strcat(nname, "~");
+ if (rename(fn, nname) < 0) {
free(nname);
return (FALSE);
}
@@ -392,6 +371,7 @@ char *dirname;
ewprintf("Bad directory name");
return NULL;
}
+ if(dirname[strlen(dirname)-1] != '/') (VOID) strcat(dirname, "/");
if((bp = findbuffer(dirname)) == NULL) {
ewprintf("Could not create buffer");
return NULL;