diff options
author | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-11-21 11:17:20 +0000 |
---|---|---|
committer | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-11-21 11:17:20 +0000 |
commit | bc02267770d4da76b22ab297041b9b9bfb720de1 (patch) | |
tree | 3da2f3872cb4019d1e016909fd17e18d1fa45e0f | |
parent | 55b6ee5b2fecd275acd8e2c4471a0fba5e493c4c (diff) |
tweaks;
-rw-r--r-- | usr.bin/rcs/rcsprog.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c index 98f33d0821e..fe7d5ec4b38 100644 --- a/usr.bin/rcs/rcsprog.c +++ b/usr.bin/rcs/rcsprog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.c,v 1.42 2005/11/20 08:50:20 xsa Exp $ */ +/* $OpenBSD: rcsprog.c,v 1.43 2005/11/21 11:17:19 xsa Exp $ */ /* * Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -204,6 +204,7 @@ rcs_statfile(char *fname, char *out, size_t len) ext = rcs_suffixes; else ext = defaultsuffix; + for (;;) { /* * GNU documentation says -x,v/ specifies two suffixes, @@ -220,15 +221,21 @@ rcs_statfile(char *fname, char *out, size_t len) *slash = '\0'; l = snprintf(filev, sizeof(filev), "%s%s", fname, ext); - if (l == -1 || l >= (int)sizeof(filev)) + if (l == -1 || l >= (int)sizeof(filev)) { + errno = ENAMETOOLONG; + cvs_log(LP_ERRNO, "%s", filev); return (-1); + } if ((strdir == 0) && (stat(RCSDIR, &st) != -1) && (st.st_mode & S_IFDIR)) { l = snprintf(fpath, sizeof(fpath), "%s/%s", RCSDIR, filev); - if (l == -1 || l >= (int)sizeof(fpath)) + if (l == -1 || l >= (int)sizeof(fpath)) { + errno = ENAMETOOLONG; + cvs_log(LP_ERRNO, "%s", fpath); return (-1); + } } else { strlcpy(fpath, filev, sizeof(fpath)); } |