kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [3/3] kudu git commit: rpc: fix too-long memcmp for HTTP methods
Date Tue, 08 Nov 2016 20:20:28 GMT
rpc: fix too-long memcmp for HTTP methods

Previously we were using arraysize(kHTTPHeader) where kHTTPHeader is a
constant "HTTP". This array would then include the terminating null
byte, which is length 5 rather than the expected length 4.
This switches to using strlen instead of arraysize.

This fixes the following ASAN error seen occasionally in tests:

==5170==ERROR: AddressSanitizer: use-after-poison on address 0x7f571f7b886c at pc 0x00000048b40c
bp 0x7f571f7b8370 sp 0x7f571f7b7b20
READ of size 5 at 0x7f571f7b886c thread T85 (negotiator [wor)
    #0 0x48b40b in memcmp /data1/jenkins-workspace/kudu-workspace/thirdparty/src/llvm-3.9.0.src/projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:628
    #1 0x7f574d3c126d in kudu::rpc::ReceiveFramedMessageBlocking(kudu::Socket*, kudu::faststring*,
google::protobuf::MessageLite*, kudu::Slice*, kudu::MonoTime const&) /data1/jenkins-workspace/kudu-workspace/src/kudu/rpc/blocking_ops.cc:103:9

Change-Id: Ic3f7be076bf0e1459d583876f65036e31034adcb
Reviewed-on: http://gerrit.cloudera.org:8080/4992
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <adar@cloudera.com>

Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/87c1a5f5
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/87c1a5f5
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/87c1a5f5

Branch: refs/heads/master
Commit: 87c1a5f50395a1913348be3d72bff1465985a77d
Parents: 20c5477
Author: Todd Lipcon <todd@apache.org>
Authored: Mon Nov 7 22:17:13 2016 -0800
Committer: Adar Dembo <adar@cloudera.com>
Committed: Tue Nov 8 20:19:40 2016 +0000

 src/kudu/rpc/blocking_ops.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/kudu/rpc/blocking_ops.cc b/src/kudu/rpc/blocking_ops.cc
index 8c1de60..4d2b201 100644
--- a/src/kudu/rpc/blocking_ops.cc
+++ b/src/kudu/rpc/blocking_ops.cc
@@ -18,6 +18,7 @@
 #include "kudu/rpc/blocking_ops.h"
 #include <stdint.h>
+#include <string.h>
 #include <glog/logging.h>
 #include <google/protobuf/message_lite.h>
@@ -100,7 +101,7 @@ Status ReceiveFramedMessageBlocking(Socket* sock, faststring* recv_buf,
   if (PREDICT_FALSE(payload_len > FLAGS_rpc_max_message_size)) {
     // A common user mistake is to try to speak the Kudu RPC protocol to an
     // HTTP endpoint, or vice versa.
-    if (memcmp(recv_buf->data(), kHTTPHeader, arraysize(kHTTPHeader)) == 0) {
+    if (memcmp(recv_buf->data(), kHTTPHeader, strlen(kHTTPHeader)) == 0) {
       return Status::IOError(
           "received invalid RPC message which appears to be an HTTP response. "
           "Verify that you have specified a valid RPC port and not an HTTP port.");

View raw message