Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37764480
en ru br
ALT Linux repos
S:2.27.0.2.ac1e-alt4
5.0: 2.15-alt2
4.1: 1.10-alt16
4.0: 1.10-alt16
3.0: 1.10-alt12

Group :: System/Libraries
RPM: libcap

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: libcap-1.10-alt-bound.patch
Download


diff -uprk.orig libcap-1.10.orig/libcap/cap_text.c libcap-1.10/libcap/cap_text.c
--- libcap-1.10.orig/libcap/cap_text.c	2003-10-13 12:31:13 +0400
+++ libcap-1.10/libcap/cap_text.c	2003-10-13 12:34:33 +0400
@@ -16,8 +16,8 @@
 #include <ctype.h>
 #include <stdio.h>
 
-/* Maximum output text length (16 per cap) */
-#define CAP_TEXT_SIZE    (16*__CAP_BITS)
+/* Maximum output text length (20 per cap) */
+#define CAP_TEXT_SIZE    (20*__CAP_BITS)
 
 #define LIBCAP_EFF   01
 #define LIBCAP_INH   02
@@ -262,7 +262,7 @@ char *cap_to_text(cap_t caps, ssize_t *l
 	    m = t;
 
     /* blank is not a valid capability set */
-    p = sprintf(buf, "=%s%s%s",
+    p = snprintf(buf, sizeof(buf), "=%s%s%s",
 		(m & LIBCAP_EFF) ? "e" : "",
 		(m & LIBCAP_INH) ? "i" : "",
 		(m & LIBCAP_PER) ? "p" : "" ) + buf;
@@ -273,9 +273,9 @@ char *cap_to_text(cap_t caps, ssize_t *l
 	    for (n = 0; n != __CAP_BITS; n++)
 		if (getstateflags(caps, n) == t) {
 		    if (_cap_names[n])
-			p += sprintf(p, "%s,", _cap_names[n]);
+			p += snprintf(p, sizeof(buf)-(p-buf), "%s,", _cap_names[n]);
 		    else
-			p += sprintf(p, "%d,", n);
+			p += snprintf(p, sizeof(buf)-(p-buf), "%d,", n);
 		    if (p - buf > CAP_TEXT_SIZE) {
 			errno = ERANGE;
 			return NULL;
@@ -284,13 +284,17 @@ char *cap_to_text(cap_t caps, ssize_t *l
 	    p--;
 	    n = t & ~m;
 	    if (n)
-		p += sprintf(p, "+%s%s%s",
+		p += snprintf(p, sizeof(buf)-(p-buf), "+%s%s%s",
 			     (n & LIBCAP_EFF) ? "e" : "",
 			     (n & LIBCAP_INH) ? "i" : "",
 			     (n & LIBCAP_PER) ? "p" : "");
+	    if (p - buf > CAP_TEXT_SIZE) {
+		errno = ERANGE;
+		return NULL;
+	    }
 	    n = ~t & m;
 	    if (n)
-		p += sprintf(p, "-%s%s%s",
+		p += snprintf(p, sizeof(buf)-(p-buf), "-%s%s%s",
 			     (n & LIBCAP_EFF) ? "e" : "",
 			     (n & LIBCAP_INH) ? "i" : "",
 			     (n & LIBCAP_PER) ? "p" : "");
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin