nss-pam-ldapd commit: r1111 - nss-pam-ldapd/nslcd
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
nss-pam-ldapd commit: r1111 - nss-pam-ldapd/nslcd
- From: "Commits of the nss-pam-ldapd project." <nss-pam-ldapd-commits [at] lists.arthurdejong.org>
- To: nss-pam-ldapd-commits [at] lists.arthurdejong.org
- Reply-to: nss-pam-ldapd-users [at] lists.arthurdejong.org
- Subject: nss-pam-ldapd commit: r1111 - nss-pam-ldapd/nslcd
- Date: Sat, 15 May 2010 17:41:25 +0200 (CEST)
Author: arthur
Date: Sat May 15 17:41:23 2010
New Revision: 1111
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?view=rev&revision=1111
Log:
always clear returned buffer when performing attribute mapping (based on a
patch by Nalin Dahyabhai <nalin@redhat.com>)
Modified:
nss-pam-ldapd/nslcd/attmap.c
nss-pam-ldapd/nslcd/attmap.h
Modified: nss-pam-ldapd/nslcd/attmap.c
==============================================================================
--- nss-pam-ldapd/nslcd/attmap.c Fri May 14 22:50:10 2010 (r1110)
+++ nss-pam-ldapd/nslcd/attmap.c Sat May 15 17:41:23 2010 (r1111)
@@ -251,20 +251,25 @@
return values[0];
}
-MUST_USE const char *attmap_get_value(MYLDAP_ENTRY *entry,const char
*attr,char *buffer,size_t buflen)
+const char *attmap_get_value(MYLDAP_ENTRY *entry,const char *attr,char
*buffer,size_t buflen)
{
const char **values;
+ /* check and clear buffer */
+ if ((buffer==NULL)||(buflen<=0))
+ return NULL;
+ buffer[0]='\0';
/* for simple values just return the attribute */
if (attr[0]!='"')
{
values=myldap_get_values(entry,attr);
- if (values==NULL)
+ if ((values==NULL)||(values[0]==NULL))
return NULL;
strncpy(buffer,values[0],buflen);
buffer[buflen-1]='\0';
return buffer;
/* TODO: maybe warn when multiple values are found */
}
+ /* we have an expression, try to parse */
if ( (attr[strlen(attr)-1]!='"') ||
(expr_parse(attr+1,buffer,buflen,entry_expand,(void *)entry)==NULL) )
{
Modified: nss-pam-ldapd/nslcd/attmap.h
==============================================================================
--- nss-pam-ldapd/nslcd/attmap.h Fri May 14 22:50:10 2010 (r1110)
+++ nss-pam-ldapd/nslcd/attmap.h Sat May 15 17:41:23 2010 (r1111)
@@ -86,11 +86,11 @@
/* Set the attribute mapping of the variable to the value specified.
Returns the new value on success. */
-
-const char *attmap_set_mapping(const char **var,const char *value);
+MUST_USE const char *attmap_set_mapping(const char **var,const char *value);
/* Return a value for the attribute, handling the case where attr
- is an expression. */
+ is an expression. On error (e.g. problem parsing expression, attribute
+ value not found) it returns NULL and the buffer is made empty. */
const char *attmap_get_value(MYLDAP_ENTRY *entry,const char *attr,char
*buffer,size_t buflen);
/* Add the attributes from attr to the set. The attr argumenent
--
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits
- nss-pam-ldapd commit: r1111 - nss-pam-ldapd/nslcd,
Commits of the nss-pam-ldapd project.