96 lines
3.4 KiB
Diff
96 lines
3.4 KiB
Diff
|
diff -up nss-pam-ldapd-0.7.16/common/tio.c.epipe2 nss-pam-ldapd-0.7.16/common/tio.c
|
||
|
--- nss-pam-ldapd-0.7.16/common/tio.c.epipe2 2012-05-14 12:37:25.534323927 +0200
|
||
|
+++ nss-pam-ldapd-0.7.16/common/tio.c 2012-05-14 12:37:49.597023102 +0200
|
||
|
@@ -312,18 +312,19 @@ int tio_read(TFILE *fp, void *buf, size_
|
||
|
}
|
||
|
}
|
||
|
|
||
|
-/* Read and discard the specified number of bytes from the stream.
|
||
|
- If count is 0 reads and discards any data that can be read and empties
|
||
|
- the read buffer. */
|
||
|
+/* Read and discard the specified number of bytes from the stream. */
|
||
|
int tio_skip(TFILE *fp, size_t count)
|
||
|
{
|
||
|
+ return tio_read(fp,NULL,count);
|
||
|
+}
|
||
|
+
|
||
|
+/* Read all available data from the stream and empty the read buffer. */
|
||
|
+int tio_skipall(TFILE *fp)
|
||
|
+{
|
||
|
+ struct timeval tv;
|
||
|
+ fd_set fdset;
|
||
|
int rv;
|
||
|
size_t len;
|
||
|
- /* for simple cases just read */
|
||
|
- if (count>0)
|
||
|
- {
|
||
|
- return tio_read(fp,NULL,count);
|
||
|
- }
|
||
|
/* clear the read buffer */
|
||
|
fp->readbuffer.start=0;
|
||
|
fp->readbuffer.len=0;
|
||
|
@@ -336,8 +337,22 @@ int tio_skip(TFILE *fp, size_t count)
|
||
|
#endif /* SSIZE_MAX */
|
||
|
while (1)
|
||
|
{
|
||
|
+ /* prepare our file descriptor set */
|
||
|
+ FD_ZERO(&fdset);
|
||
|
+ FD_SET(fp->fd,&fdset);
|
||
|
+ /* prepare the time to wait */
|
||
|
+ tv.tv_sec=0;
|
||
|
+ tv.tv_usec=0;
|
||
|
+ /* see if any data is available */
|
||
|
+ rv=select(FD_SETSIZE,&fdset,NULL,NULL,&tv);
|
||
|
+ if (rv==0)
|
||
|
+ return 0; /* no file descriptor ready */
|
||
|
+ if ((rv<0)&&((errno==EINTR)||(errno==EAGAIN)))
|
||
|
+ continue; /* interrupted, try again */
|
||
|
+ if (rv<0)
|
||
|
+ return -1; /* something went wrong */
|
||
|
+ /* read data from the stream */
|
||
|
rv=read(fp->fd,fp->readbuffer.buffer,len);
|
||
|
- /* check for errors */
|
||
|
if (rv==0)
|
||
|
return 0; /* end-of-file */
|
||
|
if ((rv<0)&&(errno==EWOULDBLOCK))
|
||
|
diff -up nss-pam-ldapd-0.7.16/common/tio.h.epipe2 nss-pam-ldapd-0.7.16/common/tio.h
|
||
|
--- nss-pam-ldapd-0.7.16/common/tio.h.epipe2 2012-05-14 12:38:17.645672445 +0200
|
||
|
+++ nss-pam-ldapd-0.7.16/common/tio.h 2012-05-14 12:38:22.621610236 +0200
|
||
|
@@ -56,11 +56,12 @@ TFILE *tio_fdopen(int fd,struct timeval
|
||
|
/* Read the specified number of bytes from the stream. */
|
||
|
int tio_read(TFILE *fp,void *buf,size_t count);
|
||
|
|
||
|
-/* Read and discard the specified number of bytes from the stream.
|
||
|
- If count is 0 reads and discards any data that can be read and empties
|
||
|
- the read buffer. */
|
||
|
+/* Read and discard the specified number of bytes from the stream. */
|
||
|
int tio_skip(TFILE *fp,size_t count);
|
||
|
|
||
|
+/* Read all available data from the stream and empty the read buffer. */
|
||
|
+int tio_skipall(TFILE *fp);
|
||
|
+
|
||
|
/* Write the specified buffer to the stream. */
|
||
|
int tio_write(TFILE *fp,const void *buf,size_t count);
|
||
|
|
||
|
diff -up nss-pam-ldapd-0.7.16/nss/common.h.epipe2 nss-pam-ldapd-0.7.16/nss/common.h
|
||
|
--- nss-pam-ldapd-0.7.16/nss/common.h.epipe2 2012-05-14 12:37:25.534323927 +0200
|
||
|
+++ nss-pam-ldapd-0.7.16/nss/common.h 2012-05-14 12:39:25.420825140 +0200
|
||
|
@@ -98,7 +98,7 @@
|
||
|
retv=readfn; \
|
||
|
/* close socket and we're done */ \
|
||
|
if ((retv==NSS_STATUS_SUCCESS)||(retv==NSS_STATUS_TRYAGAIN)) { \
|
||
|
- (void)tio_skip(fp,0); /* read any buffered data */ \
|
||
|
+ (void)tio_skipall(fp); /* read any buffered data */ \
|
||
|
(void)tio_close(fp); \
|
||
|
} \
|
||
|
return retv;
|
||
|
@@ -186,7 +186,7 @@
|
||
|
return NSS_STATUS_UNAVAIL; \
|
||
|
if (fp!=NULL) \
|
||
|
{ \
|
||
|
- (void)tio_skip(fp,0); /* read any buffered data */ \
|
||
|
+ (void)tio_skipall(fp); \
|
||
|
(void)tio_close(fp); \
|
||
|
fp=NULL; \
|
||
|
} \
|