lists.arthurdejong.org
RSS feed

nss-pam-ldapd commit: r1636 - nss-pam-ldapd/common

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

nss-pam-ldapd commit: r1636 - nss-pam-ldapd/common



Author: arthur
Date: Wed Mar 14 21:26:03 2012
New Revision: 1636
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?revision=1636&view=revision

Log:
ensure that we don't try to read more than SSIZE_MAX bytes

Modified:
   nss-pam-ldapd/common/tio.c

Modified: nss-pam-ldapd/common/tio.c
==============================================================================
--- nss-pam-ldapd/common/tio.c  Tue Mar 13 20:32:34 2012        (r1635)
+++ nss-pam-ldapd/common/tio.c  Wed Mar 14 21:26:03 2012        (r1636)
@@ -2,7 +2,7 @@
    tio.c - timed io functions
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2007, 2008, 2010 Arthur de Jong
+   Copyright (C) 2007, 2008, 2010, 2011, 2012 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
@@ -34,6 +34,7 @@
 #include <string.h>
 #include <signal.h>
 #include <stdio.h>
+#include <limits.h>
 
 #include "tio.h"
 
@@ -229,6 +230,7 @@
   int rv;
   uint8_t *tmp;
   size_t newsz;
+  size_t len;
   /* have a more convenient storage type for the buffer */
   uint8_t *ptr=(uint8_t *)buf;
   /* build a time by which we should be finished */
@@ -293,7 +295,12 @@
     if (tio_select(fp,1,&deadline))
       return -1;
     /* read the input in the buffer */
-    
rv=read(fp->fd,fp->readbuffer.buffer+fp->readbuffer.start,fp->readbuffer.size-fp->readbuffer.start);
+    len=fp->readbuffer.size-fp->readbuffer.start;
+#ifdef SSIZE_MAX
+    if (len>SSIZE_MAX)
+      len=SSIZE_MAX;
+#endif /* SSIZE_MAX */
+    rv=read(fp->fd,fp->readbuffer.buffer+fp->readbuffer.start,len);
     /* check for errors */
     if (rv==0)
     {
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits/