From e79617da9f2a4cef8711f75ffec680158e6d2b95 Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Sat, 14 Sep 2013 17:33:18 -0700
Subject: [PATCH] job_submit/pbs - Fix for incorrect malloc size

This bug in the new plugin would result in memory corruption.
---
 src/plugins/job_submit/pbs/job_submit_pbs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/plugins/job_submit/pbs/job_submit_pbs.c b/src/plugins/job_submit/pbs/job_submit_pbs.c
index 0cacbba423c..e963603d4af 100644
--- a/src/plugins/job_submit/pbs/job_submit_pbs.c
+++ b/src/plugins/job_submit/pbs/job_submit_pbs.c
@@ -126,8 +126,8 @@ static void _add_env2(struct job_descriptor *job_desc, char *key, char *val)
 	if (!job_desc->environment || !key || !val)
 		return;	/* Nothing we can do for interactive jobs */
 
-	len = sizeof(key) + sizeof(val) + 2;
-	new_env = xmalloc(sizeof(len));
+	len = strlen(key) + strlen(val) + 2;
+	new_env = xmalloc(len);
 	snprintf(new_env, len, "%s=%s", key, val);
 	_add_env(job_desc, new_env);
 	xfree(new_env);
-- 
GitLab