[Pkg-iscsi-maintainers] [SCM] Debian Open-iSCSI Packaging branch, upstream-mnc, updated. 2.0-872-193-gde2c0e7

Mike Christie michaelc at cs.wisc.edu
Sat Apr 7 15:43:51 UTC 2012


The following commit has been merged in the upstream-mnc branch:
commit aed0d2eb42295e504af09a545b06e75fd1d619f6
Author: Mike Christie <michaelc at cs.wisc.edu>
Date:   Thu Sep 1 12:17:41 2011 -0500

    iscsi tools: check NULL pointer first and add limit check in str_remove_initial
    
    We should check NULL pointer first before reference its
    member, and check the limit on the data buffer in function
    str_remove_initial.
    
    Signed-off-by: Wang Sheng-Hui <shhuiw at gmail.com>

diff --git a/usr/strings.c b/usr/strings.c
index ee6a51c..638cb4d 100644
--- a/usr/strings.c
+++ b/usr/strings.c
@@ -97,11 +97,17 @@ int str_enlarge_data(struct str_buffer *s, int length)
 
 void str_remove_initial(struct str_buffer *s, int length)
 {
-	char *remaining = s->buffer + length;
-	int amount = s->data_length - length;
+	char *remaining;
+	int amount;
 
 	if (s && length) {
-		memmove(s->buffer, remaining, amount);
+		remaining = s->buffer + length;
+		amount = s->data_length - length;
+
+		if (amount < 0)
+			amount = 0;
+		if (amount)
+			memmove(s->buffer, remaining, amount);
 		s->data_length = amount;
 		s->buffer[amount] = '\0';
 	}

-- 
Debian Open-iSCSI Packaging



More information about the Pkg-iscsi-maintainers mailing list