[zaptel-commits] mattf: trunk r1636 - /trunk/zaptel.c

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Wed Nov 22 16:23:56 MST 2006


Author: mattf
Date: Wed Nov 22 17:23:55 2006
New Revision: 1636

URL: http://svn.digium.com/view/zaptel?view=rev&rev=1636
Log:
Fix for #8403.  No extra characters in /proc/zaptel/* when reading

Modified:
    trunk/zaptel.c

Modified: trunk/zaptel.c
URL: http://svn.digium.com/view/zaptel/trunk/zaptel.c?view=diff&rev=1636&r1=1635&r2=1636
==============================================================================
--- trunk/zaptel.c (original)
+++ trunk/zaptel.c Wed Nov 22 17:23:55 2006
@@ -620,19 +620,21 @@
 				}
 				len += sprintf(page + len, "\n");
 			}
-			if ( len <= off ) /* If everything printed so far is before beginning of request */
-			{
+			if (len <= off) { /* If everything printed so far is before beginning of request */
 				off -= len;
 				len = 0;
 			}
-		}
-	}
-	if ( len <= off ) /* If everything printed so far is before beginning of request */
-	{
+			if (len > off+count) /* stop if we've already generated enough */
+				break;
+		}
+	}
+	if (len <= off) { /* If everything printed so far is before beginning of request */
 		off -= len;
 		len = 0;
 	}
 	*start = page + off;
+	len -= off;     /* un-count any remaining offset */
+	if (len > count) len = count;   /* don't return bytes not asked for */
 	return len;
 }
 #endif



More information about the zaptel-commits mailing list