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/alias.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'nslcd/alias.c') diff --git a/nslcd/alias.c b/nslcd/alias.c index 4698f1b..2bc0936 100644 --- a/nslcd/alias.c +++ b/nslcd/alias.c @@ -80,10 +80,10 @@ static int write_alias(LDAPMessage *e,struct ldap_state *pvt,FILE *fp) int nslcd_alias_byname(FILE *fp) { int32_t tmpint32; - char *name; + char name[256]; struct ldap_args a; /* read request parameters */ - READ_STRING_ALLOC(fp,name); + READ_STRING_BUF2(fp,name,sizeof(name)); /* log call */ log_log(LOG_DEBUG,"nslcd_alias_byname(%s)",name); /* write the response header */ @@ -94,8 +94,6 @@ int nslcd_alias_byname(FILE *fp) LA_STRING(a)=name; LA_TYPE(a)=LA_TYPE_STRING; _nss_ldap_searchbyname(&a,_nss_ldap_filt_getaliasbyname,LM_ALIASES,fp,write_alias); - /* no more need for this */ - free(name); WRITE_FLUSH(fp); /* we're done */ return 0; -- cgit v1.2.3