~ubuntu-branches/ubuntu/precise/nss-pam-ldapd/precise-security

« back to all changes in this revision

Viewing changes to tests/test_expr.c

  • Committer: Package Import Robot
  • Author(s): Arthur de Jong
  • Date: 2011-09-04 21:00:00 UTC
  • mfrom: (14.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20110904210000-pe3u91iga88vtr16
Tags: 0.8.4
* Upload to unstable
* switch to using the member attribute by default instead of
  uniqueMember (backwards incompatible change)
* only return "x" as a password hash when the object has the shadowAccount
  objectClass and nsswitch.conf is configured to do shadow lookups using
  LDAP (this avoids some problems with pam_unix)
* fix problem with partial attribute name matches in DN (thanks Timothy
  White)
* fix a problem with objectSid mappings with recent versions of OpenLDAP
  (patch by Wesley Mason)
* set the socket timeout in a connection callback to avoid timeout
  issues during the SSL handshake (patch by Stefan Völkel)
* check for unknown variables in pam_authz_search
* only check password expiration when authenticating, only check account
  expiration when doing authorisation
* make buffer sizes consistent and grow all buffers holding string
  representations of numbers to be able to hold 64-bit numbers
* update AX_PTHREAD from autoconf-archive
* support querying DNS SRV records from a different domain than the current
  one (based on a patch by James M. Leddy)
* fix a problem with uninitialised memory while parsing the tls_ciphers
  option (closes: #638872) (but doesn't work yet due to #640384)
* implement bounds checking of numeric values read from LDAP (patch by
  Jakub Hrozek)
* correctly support large uid and gid values from LDAP (patch by Jakub
  Hrozek)
* improvements to the configure script (patch by Jakub Hrozek)
* switch to dh for debian/rules and bump debhelper compatibility to 8
* build Debian packages with multiarch support
* ship shlibs (but still no symbol files) for libnss-ldapd since that was
  the easiest way to support multiarch
* fix output in init script when restarting nslcd (closes: #637132)
* correctly handle leading and trailing spaces in preseeded debconf uri
  option (patch by Andreas B. Mundt) (closes: #637863)
* support spaces around database names in /etc/nsswitch.conf while
  configuring package (closes: #640185)
* updated Russian debconf translation by Yuri Kozlov (closes: #637751)
* updated French debconf translation by Christian Perrier (closes: #637756)
* added Slovak debconf translation by Slavko (closes: #637759)
* updated Danish debconf translation by Joe Hansen (closes :#637763)
* updated Brazilian Portuguese debconf translation by Denis Doria
* updated Portuguese debconf translation by Américo Monteiro
* updated Japanese debconf translation by Kenshi Muto (closes: #638195)
* updated Czech debconf translation by Miroslav Kure (closes: #639026)
* updated German debconf translation by Chris Leick (closes: #639107)
* updated Spanish debconf translation by Francisco Javier Cuadrado
  (closes: #639236)
* updated Dutch debconf translation by Arthur de Jong with help from Paul
  Gevers and Jeroen Schot

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
   test_expr.c - simple tests for the expr module
3
3
   This file is part of the nss-pam-ldapd library.
4
4
 
5
 
   Copyright (C) 2009 Arthur de Jong
 
5
   Copyright (C) 2009, 2011 Arthur de Jong
6
6
 
7
7
   This library is free software; you can redistribute it and/or
8
8
   modify it under the terms of the GNU Lesser General Public
26
26
#include <string.h>
27
27
#include <assert.h>
28
28
 
 
29
#include "common.h"
 
30
 
29
31
/* we include expr.c because we want to test the static methods */
30
32
#include "common/expr.c"
31
33
 
32
 
#ifndef __ASSERT_FUNCTION
33
 
#define __ASSERT_FUNCTION ""
34
 
#endif /* not __ASSERT_FUNCTION */
35
 
 
36
 
#define assertstreq(str1,str2) \
37
 
  (assertstreq_impl(str1,str2,"strcmp(" __STRING(str1) "," __STRING(str2) ")==0", \
38
 
                    __FILE__, __LINE__, __ASSERT_FUNCTION))
39
 
 
40
 
/* for Solaris: */
41
 
#define __assert_fail(assertion,file,line,function) __assert(assertion,file,line)
42
 
 
43
 
/* method for determening string equalness */
44
 
static void assertstreq_impl(const char *str1,const char *str2,
45
 
                             const char *assertion,const char *file,
46
 
                             int line,const char *function)
47
 
{
48
 
  if (strcmp(str1,str2)!=0)
49
 
    __assert_fail(assertion,file,line,function);
50
 
}
51
 
 
52
34
static void test_parse_name(void)
53
35
{
54
36
  char buffer[20];
68
50
{
69
51
  if (strcmp(name,"empty")==0)
70
52
    return "";
 
53
  if (strcmp(name,"null")==0)
 
54
    return NULL;
71
55
  else
72
56
    return "foobar";
73
57
}
77
61
  char buffer[1024];
78
62
  assert(expr_parse("$test1",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
79
63
  assertstreq(buffer,"foobar");
 
64
  assert(expr_parse("\\$test1",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
 
65
  assertstreq(buffer,"$test1");
80
66
  assert(expr_parse("$empty",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
81
67
  assertstreq(buffer,"");
 
68
  assert(expr_parse("$foo1$empty-$foo2",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
 
69
  assertstreq(buffer,"foobar-foobar");
 
70
  assert(expr_parse("$foo1+$null+$foo2",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
 
71
  assertstreq(buffer,"foobar++foobar");
82
72
  assert(expr_parse("${test1}\\$",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
83
73
  assertstreq(buffer,"foobar$");
84
74
  assert(expr_parse("${test1:-default}",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
101
91
  assertstreq(buffer,"afoobarbfoobarec");
102
92
  assert(expr_parse("a${test1}b${test2:+${empty:-d$test4}e}c",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
103
93
  assertstreq(buffer,"afoobarbdfoobarec");
 
94
  /* these are errors */
 
95
  assert(expr_parse("$&",buffer,sizeof(buffer),expanderfn,NULL)==NULL);
 
96
  assert(expr_parse("${a",buffer,sizeof(buffer),expanderfn,NULL)==NULL);
104
97
}
105
98
 
106
99
static void test_buffer_overflow(void)