s3: net: Consider unprocessed in input buffer
authorSamuel Cabrero <scabrero@suse.de>
Fri, 7 Jun 2019 19:12:12 +0000 (21:12 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 11 Jun 2019 14:01:20 +0000 (14:01 +0000)
If there is unprocessed data in the input buffer (ilen > 0), place new
data read after the unprocessed one.

Signed-off-by: Samuel Cabrero <scabrero@suse.de>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/registry/reg_parse.c

index c64cf66a5ab8370cac4386d39246afbe65216726..24e9b62a516d800ee5d483871fa9e5ef7eaf4eb6 100644 (file)
@@ -1016,7 +1016,7 @@ int reg_parse_fd(int fd, const struct reg_parse_callback* cb, const char* opts)
                space_to_read = sizeof(buf_in) - ilen;
 
                /* Read the next chunk from the file. */
-               nread = read(fd, buf_in, space_to_read);
+               nread = read(fd, buf_in + ilen, space_to_read);
                if (nread < 0) {
                        DBG_ERR("read failed: %s\n", strerror(errno));
                        ret = -1;