summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxsa <xsa@openbsd.org>2005-04-15 14:34:15 +0000
committerxsa <xsa@openbsd.org>2005-04-15 14:34:15 +0000
commitfe0dabd9a4164e3b14a624bead23a4b2f17d22ff (patch)
tree5d546d1caf2893cab0a66cee029b3cb8db443c18
parentRemove standard defines from cpp processing, to prevent accidental (diff)
downloadwireguard-openbsd-fe0dabd9a4164e3b14a624bead23a4b2f17d22ff.tar.xz
wireguard-openbsd-fe0dabd9a4164e3b14a624bead23a4b2f17d22ff.zip
snprintf() return values checks; joris ok
-rw-r--r--usr.bin/cvs/commit.c11
-rw-r--r--usr.bin/cvs/entries.c16
2 files changed, 19 insertions, 8 deletions
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c
index ea7c55a74e0..1cfad2fbfb9 100644
--- a/usr.bin/cvs/commit.c
+++ b/usr.bin/cvs/commit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commit.c,v 1.23 2005/04/12 14:58:40 joris Exp $ */
+/* $OpenBSD: commit.c,v 1.24 2005/04/15 14:34:15 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -162,7 +162,7 @@ cvs_commit_prepare(CVSFILE *cf, void *arg)
int
cvs_commit_file(CVSFILE *cf, void *arg)
{
- int ret;
+ int ret, l;
char *repo, rcspath[MAXPATHLEN], fpath[MAXPATHLEN];
RCSFILE *rf;
struct cvsroot *root;
@@ -212,8 +212,13 @@ cvs_commit_file(CVSFILE *cf, void *arg)
}
}
- snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s",
+ l = snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s",
root->cr_dir, repo, fpath, RCS_FILE_EXT);
+ if (l == -1 || l >= (int)sizeof(rcspath)) {
+ errno = ENAMETOOLONG;
+ cvs_log(LP_ERRNO, "%s", rcspath);
+ return (-1);
+ }
cvs_ent_free(entp);
diff --git a/usr.bin/cvs/entries.c b/usr.bin/cvs/entries.c
index 254a140648d..17ed953199e 100644
--- a/usr.bin/cvs/entries.c
+++ b/usr.bin/cvs/entries.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: entries.c,v 1.25 2005/02/22 16:09:28 jfb Exp $ */
+/* $OpenBSD: entries.c,v 1.26 2005/04/15 14:34:15 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -27,11 +27,12 @@
#include <sys/param.h>
#include <sys/stat.h>
-#include <stdio.h>
+#include <errno.h>
#include <fcntl.h>
+#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
#include <string.h>
+#include <unistd.h>
#include "log.h"
#include "cvs.h"
@@ -52,7 +53,7 @@ CVSENTRIES*
cvs_ent_open(const char *dir, int flags)
{
size_t len;
- int exists;
+ int exists, l;
char entpath[MAXPATHLEN], ebuf[128], mode[4];
FILE *fp;
struct stat st;
@@ -62,7 +63,12 @@ cvs_ent_open(const char *dir, int flags)
exists = 0;
memset(mode, 0, sizeof(mode));
- snprintf(entpath, sizeof(entpath), "%s/" CVS_PATH_ENTRIES, dir);
+ l = snprintf(entpath, sizeof(entpath), "%s/" CVS_PATH_ENTRIES, dir);
+ if (l == -1 || l >= (int)sizeof(entpath)) {
+ errno = ENAMETOOLONG;
+ cvs_log(LP_ERRNO, "%s", entpath);
+ return (NULL);
+ }
switch (flags & O_ACCMODE) {
case O_WRONLY: