-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlibcap-1.10-alt-bound.diff
55 lines (52 loc) · 1.81 KB
/
libcap-1.10-alt-bound.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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" : "");