From e5a71411f3cab38fd8222c6a51d4791c330d5de7 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Wed, 27 Dec 2006 09:48:43 +0000 Subject: do not allocate new memory with malloc() for each request with a string parameter but use a buffer allocated on the stack instead (this simplifies free()-ing the buffer(s) in case of problems) git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@204 ef36b2f9-881f-0410-afb5-c4e39611909c --- nslcd/network.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'nslcd/network.c') diff --git a/nslcd/network.c b/nslcd/network.c index e44a3e1..6b13ad3 100644 --- a/nslcd/network.c +++ b/nslcd/network.c @@ -111,18 +111,17 @@ _nss_ldap_parse_net (LDAPMessage * e, int nslcd_network_byname(FILE *fp) { int32_t tmpint32; - char *name; + char name[256]; struct ldap_args a; int retv; struct netent result; char buffer[1024]; int errnop; /* read request parameters */ - READ_STRING_ALLOC(fp,name); + READ_STRING_BUF2(fp,name,sizeof(name)); /* log call */ log_log(LOG_DEBUG,"nslcd_network_byname(%s)",name); /* write the response header */ - /* FIXME: free(name) when one of these writes fails */ WRITE_INT32(fp,NSLCD_VERSION); WRITE_INT32(fp,NSLCD_ACTION_NETWORK_BYNAME); /* do the LDAP request */ @@ -130,8 +129,6 @@ int nslcd_network_byname(FILE *fp) LA_STRING(a)=name; LA_TYPE(a)=LA_TYPE_STRING; retv=nss2nslcd(_nss_ldap_getbyname(&a,&result,buffer,1024,&errnop,_nss_ldap_filt_getnetbyname,LM_NETWORKS,_nss_ldap_parse_net)); - /* no more need for this string */ - free(name); /* write the response */ WRITE_INT32(fp,retv); if (retv==NSLCD_RESULT_SUCCESS) -- cgit v1.2.3