]> Savannah Git Hosting - gnulib.git/commitdiff
selinux-h: avoid double free after *getfilecon()
authorPavel Raiskup <praiskup@redhat.com>
Wed, 1 Jul 2015 10:30:57 +0000 (12:30 +0200)
committerPádraig Brady <P@draigBrady.com>
Wed, 1 Jul 2015 11:25:34 +0000 (12:25 +0100)
Originally reported by Ben Shelton on bug-tar:
http://lists.gnu.org/archive/html/bug-tar/2015-04/msg00009.html

* lib/getfilecon.c (map_to_failure): Set the already freed '*con'
pointer to NULL.  Man getfilecon(3) says that any non-NULL '*con'
parameter should be freed by freecon(3) (regardless the return
value).

ChangeLog
lib/getfilecon.c

index d64a60696d63cdd98462fa85d8364c955174c162..94852988ab75a43ac1666d308773ed5dfc505f65 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2015-07-01  Pavel Raiskup  <praiskup@redhat.com>
+
+       selinux-h: avoid double free after *getfilecon()
+       Originally reported by Ben Shelton on bug-tar:
+       http://lists.gnu.org/archive/html/bug-tar/2015-04/msg00009.html
+       * lib/getfilecon.c (map_to_failure): Set the already freed '*con'
+       pointer to NULL.  Man getfilecon(3) says that any non-NULL '*con'
+       param should be freed by freecon(3) (regardless the return value).
+
 2015-07-01  Pavel Fedin  <p.fedin@samsung.com>
 
        fix pty related tests issues on Windows (trivial)
index 9ac69bea094fc990a0f201a30ac004f96b9f4a2b..ef6adc8d89a30185429bf16f1a122ad7214071b9 100644 (file)
@@ -57,6 +57,7 @@ map_to_failure (int ret, security_context_t *con)
   if (ret == 10 && strcmp (*con, "unlabeled") == 0)
     {
       freecon (*con);
+      *con = NULL;
       errno = ENODATA;
       return -1;
     }