summaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2019-03-15 21:22:52 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-03-15 21:22:52 -0700
commit8738462218dc9fc51a257401ed40d4f39ce2e029 (patch)
tree2f713275b2c412de638cfa8863ed9a2ebf3fe0c0 /adb
parent514fc0363865372e50ca31476e0e1ea93fd5be2d (diff)
parent3811ab5afa657b315dfc3bcfdfb70bfb3e2c1a9e (diff)
downloadsystem_core-8738462218dc9fc51a257401ed40d4f39ce2e029.tar.gz
system_core-8738462218dc9fc51a257401ed40d4f39ce2e029.tar.bz2
system_core-8738462218dc9fc51a257401ed40d4f39ce2e029.zip
Merge "adb: avoid sign extension of shell return code." am: b5ac15a936 am: a6397564b6
am: 3811ab5afa Change-Id: I334ee2c20a76a6a081b7b752d8e7ca558da3f1da
Diffstat (limited to 'adb')
-rw-r--r--adb/client/commandline.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/adb/client/commandline.cpp b/adb/client/commandline.cpp
index bb30ae570..43a3e5e94 100644
--- a/adb/client/commandline.cpp
+++ b/adb/client/commandline.cpp
@@ -295,7 +295,10 @@ int read_and_dump(int fd, bool use_shell_protocol = false,
callback->OnStderr(buffer_ptr, length);
break;
case ShellProtocol::kIdExit:
- exit_code = protocol->data()[0];
+ // data() returns a char* which doesn't have defined signedness.
+ // Cast to uint8_t to prevent 255 from being sign extended to INT_MIN,
+ // which doesn't get truncated on Windows.
+ exit_code = static_cast<uint8_t>(protocol->data()[0]);
continue;
default:
continue;