diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2007-09-23 13:06:26 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2007-09-23 13:06:26 +0200 |
commit | d355fd024e68f6c955bff1d004968b24d10b2e32 (patch) | |
tree | 5a812dfc9ddc2dddaf70f1a4d0a512dfa0626e60 /nss/common.c | |
parent | 31faddb50122d2243541d9b291bfa9b32f3e742b (diff) |
some small improvements to the code based on some source code checks
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@418 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nss/common.c')
-rw-r--r-- | nss/common.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/nss/common.c b/nss/common.c index 2735a07..f014cb8 100644 --- a/nss/common.c +++ b/nss/common.c @@ -31,6 +31,7 @@ #include <sys/stat.h> #include <errno.h> #include <nss.h> +#include <string.h> #include "nslcd.h" #include "common.h" @@ -61,8 +62,10 @@ TFILE *nslcd_client_open() if ( (sock=socket(PF_UNIX,SOCK_STREAM,0))<0 ) return NULL; /* create socket address structure */ + memset(&addr,0,sizeof(struct sockaddr_un)); addr.sun_family=AF_UNIX; - strcpy(addr.sun_path,NSLCD_SOCKET); + strncpy(addr.sun_path,NSLCD_SOCKET,sizeof(addr.sun_path)); + addr.sun_path[sizeof(addr.sun_path)-1]='\0'; /* connect to the socket */ if (connect(sock,(struct sockaddr *)&addr,(socklen_t)sizeof(struct sockaddr_un))<0) { |