richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
9fc0f6
From 540aab87440dbde3bf6a1d057df9c7a79adf7031 Mon Sep 17 00:00:00 2001
9fc0f6
From: David Herrmann <dh.herrmann@gmail.com>
9fc0f6
Date: Thu, 10 Oct 2013 13:09:37 +0200
9fc0f6
Subject: [PATCH] login: fix invalid free() in sd_session_get_vt()
9fc0f6
9fc0f6
We need to clear variables markes as _cleanup_free_. Otherwise, our
9fc0f6
error-paths might corrupt random memory.
9fc0f6
---
9fc0f6
 src/login/sd-login.c | 2 +-
9fc0f6
 1 file changed, 1 insertion(+), 1 deletion(-)
9fc0f6
9fc0f6
diff --git a/src/login/sd-login.c b/src/login/sd-login.c
9fc0f6
index 71d8c29..6c27dfe 100644
9fc0f6
--- a/src/login/sd-login.c
9fc0f6
+++ b/src/login/sd-login.c
9fc0f6
@@ -350,7 +350,7 @@ _public_ int sd_session_get_tty(const char *session, char **tty) {
9fc0f6
 }
9fc0f6
 
9fc0f6
 _public_ int sd_session_get_vt(const char *session, unsigned *vtnr) {
9fc0f6
-        _cleanup_free_ char *vtnr_string;
9fc0f6
+        _cleanup_free_ char *vtnr_string = NULL;
9fc0f6
         unsigned u;
9fc0f6
         int r;
9fc0f6