smbd: Fix a signed/unsigned comparison
authorVolker Lendecke <vl@samba.org>
Tue, 30 Jul 2019 04:55:45 +0000 (06:55 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 6 Aug 2019 21:49:28 +0000 (21:49 +0000)
In the 2nd for-loop we need a signed int as we are comparing to >=0.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/open.c

index 6759be7cf456e0c6d36aac15d6fd49f9a874df99..ee6de028a264306c4942abd1f3bb203c3d62c518 100644 (file)
@@ -4382,8 +4382,8 @@ static NTSTATUS open_streams_for_delete(connection_struct *conn,
 {
        struct stream_struct *stream_info = NULL;
        files_struct **streams = NULL;
-       int i;
-       unsigned int num_streams = 0;
+       int j;
+       unsigned int i, num_streams = 0;
        TALLOC_CTX *frame = talloc_stackframe();
        NTSTATUS status;
 
@@ -4478,14 +4478,14 @@ static NTSTATUS open_streams_for_delete(connection_struct *conn,
         * don't touch the variable "status" beyond this point :-)
         */
 
-       for (i -= 1 ; i >= 0; i--) {
-               if (streams[i] == NULL) {
+       for (j = i-1 ; j >= 0; j--) {
+               if (streams[j] == NULL) {
                        continue;
                }
 
-               DEBUG(10, ("Closing stream # %d, %s\n", i,
-                          fsp_str_dbg(streams[i])));
-               close_file(NULL, streams[i], NORMAL_CLOSE);
+               DEBUG(10, ("Closing stream # %d, %s\n", j,
+                          fsp_str_dbg(streams[j])));
+               close_file(NULL, streams[j], NORMAL_CLOSE);
        }
 
  fail: