Date: Thu, 1 May 2003 09:13:40 -0700 (PDT) From: Dag-Erling Smorgrav <des@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 30312 for review Message-ID: <200305011613.h41GDeRO068657@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=30312 Change 30312 by des@des.at.des.thinksec.com on 2003/05/01 09:13:09 Avoid dereferencing an unitialized dl handle. Also, add a cast to avoid a warning about assigning void * to a function pointer. Affected files ... .. //depot/projects/openpam/lib/openpam_dynamic.c#7 edit Differences ... ==== //depot/projects/openpam/lib/openpam_dynamic.c#7 (text+ko) ==== @@ -31,7 +31,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $P4: //depot/projects/openpam/lib/openpam_dynamic.c#6 $ + * $P4: //depot/projects/openpam/lib/openpam_dynamic.c#7 $ */ #include <dlfcn.h> @@ -57,6 +57,7 @@ void *dlh; int i; + dlh = NULL; if ((module = calloc(1, sizeof *module)) == NULL) goto buf_err; @@ -77,7 +78,7 @@ goto buf_err; module->dlh = dlh; for (i = 0; i < PAM_NUM_PRIMITIVES; ++i) { - module->func[i] = dlsym(dlh, _pam_sm_func_name[i]); + module->func[i] = (pam_func_t)dlsym(dlh, _pam_sm_func_name[i]); if (module->func[i] == NULL) openpam_log(PAM_LOG_DEBUG, "%s: %s(): %s", path, _pam_sm_func_name[i], dlerror()); @@ -85,7 +86,8 @@ return (module); buf_err: openpam_log(PAM_LOG_ERROR, "%m"); - dlclose(dlh); + if (dlh != NULL) + dlclose(dlh); free(module); return (NULL); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200305011613.h41GDeRO068657>