Avoid dereferencing an unitialized dl handle. Also, add a cast to
avoid a warning about assigning void * to a function pointer. git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@208 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
parent
13e7ee3988
commit
a57c4713cf
|
@ -31,7 +31,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $P4: //depot/projects/openpam/lib/openpam_dynamic.c#6 $
|
* $P4: //depot/projects/openpam/lib/openpam_dynamic.c#7 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
@ -57,6 +57,7 @@ openpam_dynamic(const char *path)
|
||||||
void *dlh;
|
void *dlh;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
dlh = NULL;
|
||||||
if ((module = calloc(1, sizeof *module)) == NULL)
|
if ((module = calloc(1, sizeof *module)) == NULL)
|
||||||
goto buf_err;
|
goto buf_err;
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ openpam_dynamic(const char *path)
|
||||||
goto buf_err;
|
goto buf_err;
|
||||||
module->dlh = dlh;
|
module->dlh = dlh;
|
||||||
for (i = 0; i < PAM_NUM_PRIMITIVES; ++i) {
|
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)
|
if (module->func[i] == NULL)
|
||||||
openpam_log(PAM_LOG_DEBUG, "%s: %s(): %s",
|
openpam_log(PAM_LOG_DEBUG, "%s: %s(): %s",
|
||||||
path, _pam_sm_func_name[i], dlerror());
|
path, _pam_sm_func_name[i], dlerror());
|
||||||
|
@ -85,7 +86,8 @@ openpam_dynamic(const char *path)
|
||||||
return (module);
|
return (module);
|
||||||
buf_err:
|
buf_err:
|
||||||
openpam_log(PAM_LOG_ERROR, "%m");
|
openpam_log(PAM_LOG_ERROR, "%m");
|
||||||
dlclose(dlh);
|
if (dlh != NULL)
|
||||||
|
dlclose(dlh);
|
||||||
free(module);
|
free(module);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue