Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/nslcd/ether.c
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2006-12-27 10:48:43 +0100
committerArthur de Jong <arthur@arthurdejong.org>2006-12-27 10:48:43 +0100
commite5a71411f3cab38fd8222c6a51d4791c330d5de7 (patch)
tree5922378019a29af9335b14589b5205b7661166b3 /nslcd/ether.c
parent410b6fa99387e1fcfa786a571ac34f84547bfd1e (diff)
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
Diffstat (limited to 'nslcd/ether.c')
-rw-r--r--nslcd/ether.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/nslcd/ether.c b/nslcd/ether.c
index ab7b870..c818a6d 100644
--- a/nslcd/ether.c
+++ b/nslcd/ether.c
@@ -128,7 +128,7 @@ _nss_ldap_parse_ether (LDAPMessage * e,
int nslcd_ether_byname(FILE *fp)
{
int32_t tmpint32;
- char *name;
+ char name[256];
struct ldap_args a;
/* these are here for now until we rewrite the LDAP code */
struct ether result;
@@ -136,7 +136,7 @@ int nslcd_ether_byname(FILE *fp)
int errnop;
int retv;
/* read request parameters */
- READ_STRING_ALLOC(fp,name);
+ READ_STRING_BUF2(fp,name,sizeof(name));
/* log call */
log_log(LOG_DEBUG,"nslcd_ether_byname(%s)",name);
/* write the response header */
@@ -147,8 +147,6 @@ int nslcd_ether_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_gethostton,LM_ETHERS,_nss_ldap_parse_ether));
- /* no more need for this string */
- free(name);
/* write the response */
WRITE_INT32(fp,retv);
if (retv==NSLCD_RESULT_SUCCESS)