summaryrefslogtreecommitdiffstats
path: root/xlators/features
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-06-20 11:37:44 +0200
committerAnand Avati <avati@redhat.com>2012-07-02 15:38:05 -0700
commitb535e4936d31e88595abc79a28ba87031aeccc4c (patch)
tree7a93ef1dbf70b450636e9f065d3263cd3ef9a9f7 /xlators/features
parent2310671cd15cd1639436a824922fa0a924cd6367 (diff)
pidinfo: don't let a corrupt /proc/PID/status cause buf[-1] access
Change-Id: I5d10eb92af753513eb5e5e3d7d2ad3ace57917d7 BUG: 789278 Signed-off-by: Jim Meyering <meyering@redhat.com> Reviewed-on: http://review.gluster.com/3597 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/features')
-rw-r--r--xlators/features/marker/utils/src/procdiggy.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/xlators/features/marker/utils/src/procdiggy.c b/xlators/features/marker/utils/src/procdiggy.c
index 0baab966dc5..2f81db6ad42 100644
--- a/xlators/features/marker/utils/src/procdiggy.c
+++ b/xlators/features/marker/utils/src/procdiggy.c
@@ -51,13 +51,15 @@ pidinfo (pid_t pid, char **name)
if (name)
*name = NULL;
for (;;) {
+ size_t len;
memset (buf, 0, sizeof (buf));
if (fgets (buf, sizeof (buf), f) == NULL ||
- buf[strlen (buf) - 1] != '\n') {
+ (len = strlen (buf)) == 0 ||
+ buf[len - 1] != '\n') {
pid = -1;
goto out;
}
- buf[strlen (buf) -1] = '\0';
+ buf[len - 1] = '\0';
if (name && !*name) {
p = strtail (buf, "Name:");