Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/nss/common.h
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2009-05-09 23:59:13 +0200
committerArthur de Jong <arthur@arthurdejong.org>2009-05-09 23:59:13 +0200
commit1a939483cef054ab51488c123538237290a7448e (patch)
treeb58c0c9ee33cd5c4c8df4704ca41f45076148785 /nss/common.h
parentffa068102af3e1199075cf7b1d827900758b289a (diff)
merge r882 from trunk
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@883 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nss/common.h')
-rw-r--r--nss/common.h31
1 files changed, 25 insertions, 6 deletions
diff --git a/nss/common.h b/nss/common.h
index 29a52f5..3d2de88 100644
--- a/nss/common.h
+++ b/nss/common.h
@@ -2,7 +2,7 @@
common.h - common functions for NSS lookups
Copyright (C) 2006 West Consulting
- Copyright (C) 2006, 2007, 2008 Arthur de Jong
+ Copyright (C) 2006, 2007, 2008, 2009 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -120,6 +120,12 @@ TFILE *nslcd_client_open(void)
TFILE *fp; \
int32_t tmpint32; \
enum nss_status retv; \
+ /* check that we have a valid buffer */ \
+ if ((buffer==NULL)||(buflen<=0)) \
+ { \
+ *errnop=EINVAL; \
+ return NSS_STATUS_UNAVAIL; \
+ } \
/* open socket and write request */ \
OPEN_SOCK(fp); \
WRITE_REQUEST(fp,action); \
@@ -150,9 +156,8 @@ TFILE *nslcd_client_open(void)
#define NSS_BYINT32(action,val,readfn) \
NSS_BYGEN(action,WRITE_INT32(fp,val),readfn)
-/* This macro generates a simple setent() function body. A stream
- is opened, a request is written and a check is done for
- a response header. */
+/* This macro generates a simple setent() function body. This closes any
+ open streams so that NSS_GETENT() can open a new file. */
#define NSS_SETENT(fp) \
if (fp!=NULL) \
{ \
@@ -161,11 +166,25 @@ TFILE *nslcd_client_open(void)
} \
return NSS_STATUS_SUCCESS;
-/* This macro generates a getent() function body. A single entry
- is read with the readfn() function. */
+/* This macro generates a getent() function body. If the stream is not yet
+ open, a new one is opened, a request is written and a check is done for
+ a response header. A single entry is read with the readfn() function. */
#define NSS_GETENT(fp,action,readfn) \
int32_t tmpint32; \
enum nss_status retv; \
+ /* check that we have a valid buffer */ \
+ if ((buffer==NULL)||(buflen<=0)) \
+ { \
+ /* close stream */ \
+ if (fp!=NULL) \
+ { \
+ (void)tio_close(fp); \
+ fp=NULL; \
+ } \
+ /* indicate error */ \
+ *errnop=EINVAL; \
+ return NSS_STATUS_UNAVAIL; \
+ } \
/* check that we have a valid file descriptor */ \
if (fp==NULL) \
{ \