summaryrefslogtreecommitdiffstats
path: root/usr.bin/cvs/entries.c
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 /usr.bin/cvs/entries.c
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
Diffstat (limited to 'usr.bin/cvs/entries.c')
-rw-r--r--usr.bin/cvs/entries.c16
1 files changed, 11 insertions, 5 deletions
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: