libceph: fix uninitialized value when no get_authorizer method is set
authorSage Weil <sage@newdream.net>
Thu, 12 May 2011 21:18:42 +0000 (14:18 -0700)
committerSage Weil <sage@newdream.net>
Thu, 19 May 2011 18:25:02 +0000 (11:25 -0700)
If there is no get_authorizer method we set the out_kvec to a bogus
pointer.  The length is also zero in that case, so it doesn't much matter,
but it's better not to add the empty item in the first place.

Signed-off-by: Sage Weil <sage@newdream.net>
net/ceph/messenger.c

index b140dd3515de1b46177e862a495067a98e7b1837..ce326c806237a72534b8547f47cf4fc023c2f604 100644 (file)
@@ -619,11 +619,12 @@ static int prepare_connect_authorizer(struct ceph_connection *con)
        con->out_connect.authorizer_protocol = cpu_to_le32(auth_protocol);
        con->out_connect.authorizer_len = cpu_to_le32(auth_len);
 
-       con->out_kvec[con->out_kvec_left].iov_base = auth_buf;
-       con->out_kvec[con->out_kvec_left].iov_len = auth_len;
-       con->out_kvec_left++;
-       con->out_kvec_bytes += auth_len;
-
+       if (auth_len) {
+               con->out_kvec[con->out_kvec_left].iov_base = auth_buf;
+               con->out_kvec[con->out_kvec_left].iov_len = auth_len;
+               con->out_kvec_left++;
+               con->out_kvec_bytes += auth_len;
+       }
        return 0;
 }