summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Lautrbach <plautrba@redhat.com>2012-11-05 15:37:05 (GMT)
committerPetr Lautrbach <plautrba@redhat.com>2012-11-05 15:37:05 (GMT)
commit9c823ca43b0667703d6faae97cf9c7ab753b57a1 (patch)
tree0a3b537b24adfba46b1cec45ea7dfc913cb6b0c8
parent466615c72154ff01915b3d3305ad854bf8ecc794 (diff)
downloadopenssh-9c823ca43b0667703d6faae97cf9c7ab753b57a1.zip
openssh-9c823ca43b0667703d6faae97cf9c7ab753b57a1.tar.gz
openssh-9c823ca43b0667703d6faae97cf9c7ab753b57a1.tar.xz
avoid xfree(NULL) in ssh_selinux_copy_context() (#789502)
-rw-r--r--openssh-5.9p1-sftp-chroot.patch30
1 files changed, 16 insertions, 14 deletions
diff --git a/openssh-5.9p1-sftp-chroot.patch b/openssh-5.9p1-sftp-chroot.patch
index cfe4366..bdab68a 100644
--- a/openssh-5.9p1-sftp-chroot.patch
+++ b/openssh-5.9p1-sftp-chroot.patch
@@ -1,14 +1,14 @@
-diff -up openssh-5.9p0/openbsd-compat/port-linux.c.sftp-chroot openssh-5.9p0/openbsd-compat/port-linux.c
---- openssh-5.9p0/openbsd-compat/port-linux.c.sftp-chroot 2011-09-01 04:12:22.743024608 +0200
-+++ openssh-5.9p0/openbsd-compat/port-linux.c 2011-09-01 04:12:23.069088065 +0200
-@@ -503,6 +503,23 @@ ssh_selinux_change_context(const char *n
+diff -up openssh-5.9p1/openbsd-compat/port-linux.c.sftp-chroot openssh-5.9p1/openbsd-compat/port-linux.c
+--- openssh-5.9p1/openbsd-compat/port-linux.c.sftp-chroot 2012-11-05 16:32:23.932502573 +0100
++++ openssh-5.9p1/openbsd-compat/port-linux.c 2012-11-05 16:34:28.383235006 +0100
+@@ -503,6 +503,25 @@ ssh_selinux_change_context(const char *n
xfree(newctx);
}
+void
+ssh_selinux_copy_context(void)
+{
-+ char *ctx;
++ security_context_t *ctx;
+
+ if (!ssh_selinux_enabled())
+ return;
@@ -17,17 +17,19 @@ diff -up openssh-5.9p0/openbsd-compat/port-linux.c.sftp-chroot openssh-5.9p0/ope
+ logit("%s: getcon failed with %s", __func__, strerror (errno));
+ return;
+ }
-+ if (setcon(ctx) < 0)
-+ logit("%s: setcon failed with %s", __func__, strerror (errno));
-+ xfree(ctx);
++ if (ctx != NULL) {
++ if (setcon(ctx) < 0)
++ logit("%s: setcon failed with %s", __func__, strerror (errno));
++ freecon(ctx);
++ }
+}
+
#endif /* WITH_SELINUX */
#ifdef LINUX_OOM_ADJUST
-diff -up openssh-5.9p0/openbsd-compat/port-linux.h.sftp-chroot openssh-5.9p0/openbsd-compat/port-linux.h
---- openssh-5.9p0/openbsd-compat/port-linux.h.sftp-chroot 2011-01-25 02:16:18.000000000 +0100
-+++ openssh-5.9p0/openbsd-compat/port-linux.h 2011-09-01 04:12:23.163088777 +0200
+diff -up openssh-5.9p1/openbsd-compat/port-linux.h.sftp-chroot openssh-5.9p1/openbsd-compat/port-linux.h
+--- openssh-5.9p1/openbsd-compat/port-linux.h.sftp-chroot 2011-01-25 02:16:18.000000000 +0100
++++ openssh-5.9p1/openbsd-compat/port-linux.h 2012-11-05 16:32:23.935502591 +0100
@@ -24,6 +24,7 @@ int ssh_selinux_enabled(void);
void ssh_selinux_setup_pty(char *, const char *);
void ssh_selinux_setup_exec_context(char *);
@@ -36,9 +38,9 @@ diff -up openssh-5.9p0/openbsd-compat/port-linux.h.sftp-chroot openssh-5.9p0/ope
void ssh_selinux_setfscreatecon(const char *);
#endif
-diff -up openssh-5.9p0/session.c.sftp-chroot openssh-5.9p0/session.c
---- openssh-5.9p0/session.c.sftp-chroot 2011-09-01 04:12:19.698049195 +0200
-+++ openssh-5.9p0/session.c 2011-09-01 04:40:03.598148719 +0200
+diff -up openssh-5.9p1/session.c.sftp-chroot openssh-5.9p1/session.c
+--- openssh-5.9p1/session.c.sftp-chroot 2012-11-05 16:32:23.913502453 +0100
++++ openssh-5.9p1/session.c 2012-11-05 16:32:23.935502591 +0100
@@ -1519,6 +1519,9 @@ do_setusercontext(struct passwd *pw)
pw->pw_uid);
chroot_path = percent_expand(tmp, "h", pw->pw_dir,