diff options
author | 2000-02-27 05:49:14 +0000 | |
---|---|---|
committer | 2000-02-27 05:49:14 +0000 | |
commit | d7d773a622007dc99c7b506f541dc57e0ea9b386 (patch) | |
tree | 63f5b974835f7daf9f9ee7b79c90af3f08d805f9 | |
parent | repair some gotchas in the .{u,}{mul,div,rem} replacement routines, out of a conversation with torek (diff) | |
download | wireguard-openbsd-d7d773a622007dc99c7b506f541dc57e0ea9b386.tar.xz wireguard-openbsd-d7d773a622007dc99c7b506f541dc57e0ea9b386.zip |
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.
-rw-r--r-- | usr.bin/mg/fileio.c | 26 |
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; |