lists.arthurdejong.org
RSS feed

nss-pam-ldapd commit: r1471 - in nss-pam-ldapd: common tests

[Date Prev][Date Next] [Thread Prev][Thread Next]

nss-pam-ldapd commit: r1471 - in nss-pam-ldapd: common tests



Author: arthur
Date: Sun Jun  5 11:14:12 2011
New Revision: 1471
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?view=rev&revision=1471

Log:
handle expressions where the expander function returns NULL (handle it as an 
empty string)

Modified:
   nss-pam-ldapd/common/expr.c
   nss-pam-ldapd/tests/test_expr.c

Modified: nss-pam-ldapd/common/expr.c
==============================================================================
--- nss-pam-ldapd/common/expr.c Sun Jun  5 10:58:35 2011        (r1470)
+++ nss-pam-ldapd/common/expr.c Sun Jun  5 11:14:12 2011        (r1471)
@@ -93,6 +93,8 @@
     if (parse_name(str,ptr,varname,sizeof(varname))==NULL)
       return NULL;
     varvalue=expander(varname,expander_arg);
+    if (varvalue==NULL)
+      varvalue="";
     if (str[*ptr]=='}')
     {
       /* simple substitute */
@@ -148,6 +150,8 @@
     if (parse_name(str,ptr,varname,sizeof(varname))==NULL)
       return NULL;
     varvalue=expander(varname,expander_arg);
+    if (varvalue==NULL)
+      varvalue="";
     if (strlen(varvalue)>=buflen)
       return NULL;
     strcpy(buffer,varvalue);

Modified: nss-pam-ldapd/tests/test_expr.c
==============================================================================
--- nss-pam-ldapd/tests/test_expr.c     Sun Jun  5 10:58:35 2011        (r1470)
+++ nss-pam-ldapd/tests/test_expr.c     Sun Jun  5 11:14:12 2011        (r1471)
@@ -50,6 +50,8 @@
 {
   if (strcmp(name,"empty")==0)
     return "";
+  if (strcmp(name,"null")==0)
+    return NULL;
   else
     return "foobar";
 }
@@ -65,6 +67,8 @@
   assertstreq(buffer,"");
   
assert(expr_parse("$foo1$empty-$foo2",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
   assertstreq(buffer,"foobar-foobar");
+  
assert(expr_parse("$foo1+$null+$foo2",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
+  assertstreq(buffer,"foobar++foobar");
   
assert(expr_parse("${test1}\\$",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
   assertstreq(buffer,"foobar$");
   
assert(expr_parse("${test1:-default}",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits