lib: Use iov_buf in smbXcli_iov_concat
authorVolker Lendecke <vl@samba.org>
Tue, 17 Feb 2015 20:17:35 +0000 (20:17 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 24 Feb 2015 16:52:09 +0000 (17:52 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
libcli/smb/smbXcli_base.c

index f8d4df3c14ffee2f217060043ed4c55e095d29a9..b9c3c8b836cc80bb7a25bb8e81ed7c267f5765cd 100644 (file)
@@ -1126,20 +1126,21 @@ static uint8_t *smbXcli_iov_concat(TALLOC_CTX *mem_ctx,
                                   const struct iovec *iov,
                                   int count)
 {
-       size_t len = smbXcli_iov_len(iov, count);
-       size_t copied;
+       ssize_t buflen;
        uint8_t *buf;
-       int i;
 
-       buf = talloc_array(mem_ctx, uint8_t, len);
-       if (buf == NULL) {
+       buflen = iov_buflen(iov, count);
+       if (buflen == -1) {
                return NULL;
        }
-       copied = 0;
-       for (i=0; i<count; i++) {
-               memcpy(buf+copied, iov[i].iov_base, iov[i].iov_len);
-               copied += iov[i].iov_len;
+
+       buf = talloc_array(mem_ctx, uint8_t, buflen);
+       if (buf == NULL) {
+               return NULL;
        }
+
+       iov_buf(iov, count, buf, buflen);
+
        return buf;
 }