diff options
author | 2005-06-01 14:03:14 +0000 | |
---|---|---|
committer | 2005-06-01 14:03:14 +0000 | |
commit | b6f8daab5a9d86e05947b9406ffd3613aab17265 (patch) | |
tree | 932c35552572d59c6a30e5ded14a20414614cf01 /usr.bin/cvs/file.c | |
parent | when dumping policies, skip those attached to a socket. (diff) | |
download | wireguard-openbsd-b6f8daab5a9d86e05947b9406ffd3613aab17265.tar.xz wireguard-openbsd-b6f8daab5a9d86e05947b9406ffd3613aab17265.zip |
when creating a new directory, steal the parent its cvsroot structure if
we cannot find one with cvsroot_get().
fixes several segfaults.
tested & ok xsa@
Diffstat (limited to 'usr.bin/cvs/file.c')
-rw-r--r-- | usr.bin/cvs/file.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index 2b33fc4e083..100a7f44c3a 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.83 2005/05/31 08:58:48 xsa Exp $ */ +/* $OpenBSD: file.c,v 1.84 2005/06/01 14:03:14 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -249,6 +249,7 @@ CVSFILE* cvs_file_create(CVSFILE *parent, const char *path, u_int type, mode_t mode) { int fd; + int bail; char fp[MAXPATHLEN]; CVSFILE *cfp; CVSENTRIES *ent; @@ -257,13 +258,36 @@ cvs_file_create(CVSFILE *parent, const char *path, u_int type, mode_t mode) if (cfp == NULL) return (NULL); + bail = 0; cfp->cf_mode = mode; cfp->cf_parent = parent; if (type == DT_DIR) { cfp->cf_root = cvsroot_get(path); - cfp->cf_repo = strdup(cvs_file_getpath(cfp, - fp, sizeof(fp))); + + /* + * If we do not have a valid root for this, try looking at + * the parent its root. + */ + if (cfp->cf_root == NULL) { + if (parent != NULL && parent->cf_root != NULL) { + cfp->cf_root = + cvsroot_parse(parent->cf_root->cr_str); + if (cfp->cf_root == NULL) + bail = 1; + } else { + bail = 1; + } + } + + /* we tried, too bad */ + if (bail) { + cvs_log(LP_ERR, "failed to obtain root info for `%s'", + path); + return (NULL); + } + + cfp->cf_repo = strdup(cvs_file_getpath(cfp, fp, sizeof(fp))); if (cfp->cf_repo == NULL) { cvs_file_free(cfp); return (NULL); |