diff options
author | Andrew G. Morgan <morgan@kernel.org> | 2008-07-06 12:11:42 -0700 |
---|---|---|
committer | Andrew G. Morgan <morgan@kernel.org> | 2008-07-06 12:11:42 -0700 |
commit | 3463a1393551bff930d19e50417e6e57f1df7324 (patch) | |
tree | 26c2218be8e46c6a7ccb340cbaa259c5c4135248 /contrib | |
parent | 3fa808f5886d08c45866217cfe6e6e9def7de04e (diff) | |
download | libcap2-3463a1393551bff930d19e50417e6e57f1df7324.tar.gz |
Fix for Debian bugs 400591 & 487223: cap_copy_ext()
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=400591
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=487223
Correct fix implemented as suggested by Matt.
Reported-by: Matt Kern <matt.kern@undue.org>
Reported-by: Torsten Werner <twerner@debian.org>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/bug400591/Makefile | 8 | ||||
-rw-r--r-- | contrib/bug400591/bug.c | 44 |
2 files changed, 52 insertions, 0 deletions
diff --git a/contrib/bug400591/Makefile b/contrib/bug400591/Makefile new file mode 100644 index 0000000..f6e0ea3 --- /dev/null +++ b/contrib/bug400591/Makefile @@ -0,0 +1,8 @@ +all: bug + +bug: bug.c ../../libcap Makefile + make -C ../../libcap + cc --static -o $@ $< -L../../libcap -lcap + +clean: + rm -f bug.o bug diff --git a/contrib/bug400591/bug.c b/contrib/bug400591/bug.c new file mode 100644 index 0000000..363ca27 --- /dev/null +++ b/contrib/bug400591/bug.c @@ -0,0 +1,44 @@ +#include <assert.h> +#include <stdlib.h> +#include <sys/capability.h> + +/* + * Original from http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=400591 + * + * Modified to test more functions.. AGM - 2008/07/06. + */ + +int main (int argc, char *argv[]) +{ + cap_t caps, caps2; + ssize_t size, copy_size; + void *buffer; + char *text1, *text2; + + caps = cap_init(); + assert (caps); + + assert(capgetp(1, caps) == 0); + + text1 = cap_to_text(caps, NULL); + assert(text1); + + size = cap_size (caps); + assert (size>0 && size<1024); + + buffer = malloc (size); + assert (buffer); + + copy_size = cap_copy_ext (buffer, caps, size); + assert (copy_size == size); + + caps2 = cap_copy_int(buffer); + assert (caps2); + + text2 = cap_to_text(caps, NULL); + assert(text2); + + assert(strcmp(text1, text2) == 0); + + return 0; +} |