rpms/mcs/devel libmcs-0.7.1-util.patch,NONE,1.1 mcs.spec,1.15,1.16

Michael Schwendt mschwendt at fedoraproject.org
Thu Dec 24 21:22:26 UTC 2009


Author: mschwendt

Update of /cvs/pkgs/rpms/mcs/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv4104

Modified Files:
	mcs.spec 
Added Files:
	libmcs-0.7.1-util.patch 
Log Message:
* Thu Dec 24 2009 Michael Schwendt <mschwendt at fedoraproject.org> - 0.7.1-8
- Apply safety fixes to string utility functions.


libmcs-0.7.1-util.patch:
 mcs_util.c |   29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

--- NEW FILE libmcs-0.7.1-util.patch ---
diff -Nur libmcs-0.7.1-orig/src/libmcs/mcs_util.c libmcs-0.7.1/src/libmcs/mcs_util.c
--- libmcs-0.7.1-orig/src/libmcs/mcs_util.c	2008-04-21 00:05:48.000000000 +0200
+++ libmcs-0.7.1/src/libmcs/mcs_util.c	2009-12-24 18:26:15.000000000 +0100
@@ -56,7 +56,7 @@
  *
  * \param str The string to duplicate.
  * \param len The maximum allowed length of the string.
- * \return The length of the string or len, whichever is smaller.
+ * \return The pointer to a copy of the string. Free this with free().
  */
 char *
 mcs_strndup(const char *str, size_t len)
@@ -68,7 +68,7 @@
 		return NULL;
 
 	memcpy(out, str, nlen);
-	out[len] = '\0';
+	out[nlen] = '\0';
 
 	return out;
 }
@@ -146,16 +146,22 @@
 {
 	size_t dsize = strlen(dest);
 	size_t len = strlen(src);
-	size_t res = dsize + len;
+	size_t res;
 
 	dest += dsize;
 	count -= dsize;
 
-	if (len >= count)
-		len = count - 1;
-
+	if (len >= count) {
+        if (count>0) {
+            len = count - 1;
+        }
+        else {
+            len = 0;
+        }
+    }
 	memcpy(dest, src, len);
 	dest[len] = 0;
+    res = dsize + len;
 
 	return res;
 }
@@ -172,15 +178,16 @@
  */
 size_t mcs_strlcpy(char *dest, const char *src, size_t size)
 {
-	size_t ret = strlen(src);
+	size_t srclen = strlen(src);
+    size_t retlen = 0;
 
 	if (size != 0)
 	{
-		size_t len = (ret >= size) ? size - 1 : ret;
-		memcpy(dest, src, len);
-		dest[len] = '\0';
+		retlen = (srclen >= size) ? size - 1 : srclen;
+		memcpy(dest, src, retlen);
+		dest[retlen] = '\0';
 	}
 
-	return ret;
+	return retlen;
 }
 


Index: mcs.spec
===================================================================
RCS file: /cvs/pkgs/rpms/mcs/devel/mcs.spec,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -p -r1.15 -r1.16
--- mcs.spec	23 Dec 2009 23:14:00 -0000	1.15
+++ mcs.spec	24 Dec 2009 21:22:26 -0000	1.16
@@ -1,6 +1,6 @@
 Name:           mcs
 Version:        0.7.1
-Release:        7%{?dist}
+Release:        8%{?dist}
 Summary:        Configuration file abstraction system
 
 Group:          Applications/System
@@ -10,8 +10,12 @@ License:        BSD
 URL:            http://atheme.org
 
 Source0:        http://distfiles.atheme.org/libmcs-%{version}.tgz
+# submitted upstream, build config fix
 Patch0: libmcs-0.7.1-sysconfdir.patch
+# submitted upstream, floating point exception fix
 Patch1: libmcs-0.7.1-walk.patch
+# submitted upstream, safety fixes in string utility functions
+Patch2: libmcs-0.7.1-util.patch
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -84,6 +88,7 @@ This package contains the files necessar
 %setup -q -n libmcs-%{version}
 %patch0 -p1 -b .sysconfdir
 %patch1 -p1 -b .walk
+%patch2 -p1 -b .util
 
 # Make the build system more verbose
 #perl -pi -e 's/^\.SILENT:.*$//' buildsys.mk.in
@@ -137,6 +142,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/pkgconfig/libmcs.pc
 
 %changelog
+* Thu Dec 24 2009 Michael Schwendt <mschwendt at fedoraproject.org> - 0.7.1-8
+- Apply safety fixes to string utility functions.
+
 * Thu Dec 24 2009 Michael Schwendt <mschwendt at fedoraproject.org> - 0.7.1-7
 - Fix floating point exception in mcs-walk-config tool.
 




More information about the fedora-extras-commits mailing list