From: Derrick Brashear Date: Mon, 20 Dec 2010 21:36:42 +0000 (-0500) Subject: LWP: don't copy pid to a null pointer X-Git-Tag: upstream/1.6.3^2~40 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=e64921531a0f100c269c659d6500a8b358e23f87;p=packages%2Fo%2Fopenafs.git LWP: don't copy pid to a null pointer In LWP_CreateProcess we take a pid. if it's null, don't crash. Reviewed-on: http://gerrit.openafs.org/3556 Reviewed-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit 5d218831f3186d0d1dc7d3b00dd4a3b6a4a8757c) Change-Id: I96c0e2a8858fa929f0de22a774050aa63a200101 Reviewed-on: http://gerrit.openafs.org/9414 Tested-by: BuildBot Reviewed-by: Derrick Brashear Reviewed-by: Andrew Deason Reviewed-by: Michael Meffie Reviewed-by: Stephan Wiesand --- diff --git a/src/lwp/lwp.c b/src/lwp/lwp.c index 0b3f80b9c..35eb8cf3e 100644 --- a/src/lwp/lwp.c +++ b/src/lwp/lwp.c @@ -418,7 +418,8 @@ LWP_CreateProcess(void *(*ep) (void *), int stacksize, int priority, void *parm, /* End of gross hack */ Set_LWP_RC(); - *pid = temp; + if (pid) + *pid = temp; return 0; } else return LWP_EINIT; @@ -484,7 +485,8 @@ LWP_CreateProcess2(void *(*ep) (void *), int stacksize, int priority, void *parm /* End of gross hack */ Set_LWP_RC(); - *pid = temp; + if (pid) + *pid = temp; return 0; } else return LWP_EINIT; @@ -641,7 +643,8 @@ LWP_InitializeProcessSupport(int priority, PROCESS * pid) savecontext(Dispatcher, &temp->context, NULL); LWPANCHOR.outersp = temp->context.topstack; Set_LWP_RC(); - *pid = temp; + if (pid) + *pid = temp; /* get minimum stack size from the environment. this allows the administrator * to change the lwp stack dynamically without getting a new binary version. @@ -1443,7 +1446,8 @@ LWP_CreateProcess(pthread_startroutine_t ep, int stacksize, int priority, free(lp); return LWP_ENOMEM; } - *pid = lp; + if (pid) + *pid = lp; return LWP_SUCCESS; } @@ -1494,7 +1498,8 @@ LWP_InitializeProcessSupport(int priority, PROCESS * pid) int state; if (initialized) { - *pid = lp; + if (pid) + *pid = lp; return LWP_SUCCESS; } #ifndef LWP_NO_PRIORITIES @@ -1519,7 +1524,8 @@ LWP_InitializeProcessSupport(int priority, PROCESS * pid) MUTEX_INIT(&lwp_mutex, "lwp", MUTEX_DEFAULT, 0); MUTEX_ENTER(&lwp_mutex); initialized = 1; - *pid = lp; + if (pid) + *pid = lp; return LWP_SUCCESS; }