=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/util.c,v retrieving revision 1.77 retrieving revision 1.78 diff -c -r1.77 -r1.78 *** src/usr.bin/cvs/util.c 2006/04/05 01:38:56 1.77 --- src/usr.bin/cvs/util.c 2006/04/14 02:45:35 1.78 *************** *** 1,4 **** ! /* $OpenBSD: util.c,v 1.77 2006/04/05 01:38:56 ray Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * Copyright (c) 2005, 2006 Joris Vink --- 1,4 ---- ! /* $OpenBSD: util.c,v 1.78 2006/04/14 02:45:35 deraadt Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * Copyright (c) 2005, 2006 Joris Vink *************** *** 100,106 **** return (-1); } dlen = strlen(dst); ! if ((dlen > 0) && (dst[dlen - 1] == '\n')) dst[--dlen] = '\0'; (void)fclose(fp); --- 100,106 ---- return (-1); } dlen = strlen(dst); ! if (dlen > 0 && dst[dlen - 1] == '\n') dst[--dlen] = '\0'; (void)fclose(fp); *************** *** 145,152 **** continue; } ! if ((type <= 'a') || (type >= 'z') || ! (cvs_modetypes[type - 'a'] == -1)) { cvs_log(LP_WARN, "invalid mode type `%c'" " (`u', `g' or `o' expected), ignoring", type); --- 145,152 ---- continue; } ! if (type <= 'a' || type >= 'z' || ! cvs_modetypes[type - 'a'] == -1) { cvs_log(LP_WARN, "invalid mode type `%c'" " (`u', `g' or `o' expected), ignoring", type); *************** *** 157,164 **** type = cvs_modetypes[type - 'a']; for (sp = ms; *sp != '\0'; sp++) { ! if ((*sp <= 'a') || (*sp >= 'z') || ! (cvs_modes[(int)type][*sp - 'a'] == 0)) { cvs_log(LP_WARN, "invalid permission bit `%c'", *sp); } else --- 157,164 ---- type = cvs_modetypes[type - 'a']; for (sp = ms; *sp != '\0'; sp++) { ! if (*sp <= 'a' || *sp >= 'z' || ! cvs_modes[(int)type][*sp - 'a'] == 0) { cvs_log(LP_WARN, "invalid permission bit `%c'", *sp); } else *************** *** 270,276 **** if ((rlen = strlcpy(base, path, blen)) >= blen) fatal("cvs_splitpath: path truncation"); ! while ((rlen > 0) && (base[rlen - 1] == '/')) base[--rlen] = '\0'; sp = strrchr(base, '/'); --- 270,276 ---- if ((rlen = strlcpy(base, path, blen)) >= blen) fatal("cvs_splitpath: path truncation"); ! while (rlen > 0 && base[rlen - 1] == '/') base[--rlen] = '\0'; sp = strrchr(base, '/'); *************** *** 436,442 **** if (l >= sizeof(path)) fatal("cvs_mkadmin: path truncation"); ! if ((mkdir(path, 0755) == -1) && (errno != EEXIST)) fatal("cvs_mkadmin: mkdir: `%s': %s", path, strerror(errno)); /* just create an empty Entries file */ --- 436,442 ---- if (l >= sizeof(path)) fatal("cvs_mkadmin: path truncation"); ! if (mkdir(path, 0755) == -1 && errno != EEXIST) fatal("cvs_mkadmin: mkdir: `%s': %s", path, strerror(errno)); /* just create an empty Entries file */ *************** *** 448,454 **** if (l >= sizeof(path)) fatal("cvs_mkadmin: path truncation"); ! if ((stat(path, &st) == -1) && (errno == ENOENT)) { if ((fp = fopen(path, "w")) == NULL) fatal("cvs_mkadmin: fopen: `%s': %s", path, strerror(errno)); --- 448,454 ---- if (l >= sizeof(path)) fatal("cvs_mkadmin: path truncation"); ! if (stat(path, &st) == -1 && errno == ENOENT) { if ((fp = fopen(path, "w")) == NULL) fatal("cvs_mkadmin: fopen: `%s': %s", path, strerror(errno)); *************** *** 462,468 **** if (l >= sizeof(path)) fatal("cvs_mkadmin: path truncation"); ! if ((stat(path, &st) == -1) && (errno == ENOENT)) { if ((fp = fopen(path, "w")) == NULL) fatal("cvs_mkadmin: fopen: `%s': %s", path, strerror(errno)); --- 462,468 ---- if (l >= sizeof(path)) fatal("cvs_mkadmin: path truncation"); ! if (stat(path, &st) == -1 && errno == ENOENT) { if ((fp = fopen(path, "w")) == NULL) fatal("cvs_mkadmin: fopen: `%s': %s", path, strerror(errno)); *************** *** 560,566 **** if (cvs_noexec == 1) return (0); ! if ((unlink(path) == -1) && (errno != ENOENT)) { cvs_log(LP_ERRNO, "cannot remove `%s'", path); return (-1); } --- 560,566 ---- if (cvs_noexec == 1) return (0); ! if (unlink(path) == -1 && errno != ENOENT) { cvs_log(LP_ERRNO, "cannot remove `%s'", path); return (-1); } *************** *** 605,616 **** if (ent->d_type == DT_DIR) { if (cvs_rmdir(fpath) == -1) goto done; ! } else if ((cvs_unlink(fpath) == -1) && (errno != ENOENT)) goto done; } ! if ((rmdir(path) == -1) && (errno != ENOENT)) { cvs_log(LP_ERRNO, "failed to remove '%s'", path); goto done; } --- 605,616 ---- if (ent->d_type == DT_DIR) { if (cvs_rmdir(fpath) == -1) goto done; ! } else if (cvs_unlink(fpath) == -1 && errno != ENOENT) goto done; } ! if (rmdir(path) == -1 && errno != ENOENT) { cvs_log(LP_ERRNO, "failed to remove '%s'", path); goto done; } *************** *** 635,641 **** CVSENTRIES *entf; struct cvs_ent *ent; ! if ((create_adm == 1) && (root == NULL)) fatal("cvs_create_dir failed"); s = xstrdup(path); --- 635,641 ---- CVSENTRIES *entf; struct cvs_ent *ent; ! if (create_adm == 1 && root == NULL) fatal("cvs_create_dir failed"); s = xstrdup(path); *************** *** 654,661 **** while (d != NULL) { if (stat(d, &sb)) { /* try to create the directory */ ! if ((errno != ENOENT) || (mkdir(d, 0755) && ! errno != EEXIST)) { cvs_log(LP_ERRNO, "failed to create `%s'", d); goto done; } --- 654,661 ---- while (d != NULL) { if (stat(d, &sb)) { /* try to create the directory */ ! if (errno != ENOENT || ! (mkdir(d, 0755) && errno != EEXIST)) { cvs_log(LP_ERRNO, "failed to create `%s'", d); goto done; } *************** *** 799,805 **** if (strlcpy(tagpath, CVS_PATH_TAG, sizeof(tagpath)) >= sizeof(tagpath)) return; ! if ((tag != NULL) || (date != NULL)) { fp = fopen(tagpath, "w+"); if (fp == NULL) { if (errno != ENOENT) --- 799,805 ---- if (strlcpy(tagpath, CVS_PATH_TAG, sizeof(tagpath)) >= sizeof(tagpath)) return; ! if (tag != NULL || date != NULL) { fp = fopen(tagpath, "w+"); if (fp == NULL) { if (errno != ENOENT)