Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Aug 2000 01:29:59 -0700 (PDT)
From:      Kris Kennaway <kris@hub.freebsd.org>
To:        audit@freebsd.org
Subject:   catopen() patch
Message-ID:  <Pine.BSF.4.21.0008040128220.66197-100000@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Can someone please review the following patch?

Kris

Index: msgcat.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/nls/msgcat.c,v
retrieving revision 1.21
diff -u -r1.21 msgcat.c
--- msgcat.c	2000/01/27 23:06:33	1.21
+++ msgcat.c	2000/08/04 08:20:36
@@ -91,8 +91,9 @@
     __const char *catpath = NULL;
     char        *nlspath;
     char	*lang;
-    long	len;
     char	*base, *cptr, *pathP;
+    int		spcleft;
+    long	len;
     struct stat	sbuf;
 
     if (!name || !*name) {
@@ -129,13 +130,20 @@
 		*cptr = '\0';
 		for (pathP = path; *nlspath; ++nlspath) {
 		    if (*nlspath == '%') {
+		        spcleft = sizeof(path) - (pathP - path);
 			if (*(nlspath + 1) == 'L') {
 			    ++nlspath;
-			    strcpy(pathP, lang);
+			    if (strlcpy(pathP, lang, spcleft) >= spcleft) {
+				errno = ENAMETOOLONG;
+				return(NLERR);
+			    }
 			    pathP += strlen(lang);
 			} else if (*(nlspath + 1) == 'N') {
 			    ++nlspath;
-			    strcpy(pathP, name);
+			    if (strlcpy(pathP, name, spcleft) >= spcleft) {
+			        errno = ENAMETOOLONG;
+				return(NLERR);
+			    }
 			    pathP += strlen(name);
 			} else *(pathP++) = *nlspath;
 		    } else *(pathP++) = *nlspath;

--
In God we Trust -- all others must submit an X.509 certificate.
    -- Charles Forsythe <forsythe@alum.mit.edu>



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0008040128220.66197-100000>