winbind: Fix error check in unpack_tdc_domains
authorVolker Lendecke <vl@samba.org>
Fri, 11 Jan 2013 13:02:52 +0000 (14:02 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 11 Jan 2013 16:10:49 +0000 (17:10 +0100)
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/winbindd/winbindd_cache.c

index 76970d6be404178700b2c265028fc9d44c68f92e..fbfaa1dbafb5482d61afee4aa27a444dda5c09c4 100644 (file)
@@ -4455,7 +4455,9 @@ static size_t unpack_tdc_domains( unsigned char *buf, int buflen,
        }
 
        for ( i=0; i<num_domains; i++ ) {
-               len += tdb_unpack( buf+len, buflen-len, "fffddd",
+               int this_len;
+
+               this_len = tdb_unpack( buf+len, buflen-len, "fffddd",
                                   domain_name,
                                   dns_name,
                                   sid_string,
@@ -4463,11 +4465,12 @@ static size_t unpack_tdc_domains( unsigned char *buf, int buflen,
                                   &attribs,
                                   &type );
 
-               if ( len == -1 ) {
+               if ( this_len == -1 ) {
                        DEBUG(5,("unpack_tdc_domains: Failed to unpack domain array\n"));
                        TALLOC_FREE( list );                    
                        return 0;
                }
+               len += this_len;
 
                DEBUG(11,("unpack_tdc_domains: Unpacking domain %s (%s) "
                          "SID %s, flags = 0x%x, attribs = 0x%x, type = 0x%x\n",