[gnome-keyring/dbus-api] [egg] Null terminate credentials read from /proc
- From: Stefan Walter <stefw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-keyring/dbus-api] [egg] Null terminate credentials read from /proc
- Date: Sat, 26 Sep 2009 01:55:35 +0000 (UTC)
commit 21c2cd0c5edef9ed9f9e6c71a09215d976ab846d
Author: Stef Walter <stef memberwebs com>
Date: Sat Sep 26 01:52:22 2009 +0000
[egg] Null terminate credentials read from /proc
The process command name read from /proc was not null terminated
in the previous code.
egg/egg-unix-credentials.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/egg/egg-unix-credentials.c b/egg/egg-unix-credentials.c
index 9de1c76..13b2048 100644
--- a/egg/egg-unix-credentials.c
+++ b/egg/egg-unix-credentials.c
@@ -217,17 +217,19 @@ egg_unix_credentials_executable (pid_t pid)
#if defined(__linux__) || defined(__FreeBSD__)
char path[1024];
char buffer[64];
-
+ int count;
+
#if defined(__linux__)
snprintf (buffer, sizeof (buffer), "/proc/%d/exe", (int)pid);
#elif defined(__FreeBSD__)
snprintf (buffer, sizeof (buffer), "/proc/%d/file", (int)pid);
#endif
-
- if (readlink(buffer, path, sizeof (path)) < 0)
+
+ count = readlink (buffer, path, sizeof (path));
+ if (count < 0)
fprintf (stderr, "readlink failed for file: %s", buffer);
else
- result = strdup (path);
+ result = strndup (path, count);
#endif
return result;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]