| Index: tools/android/forwarder2/forwarder.cc
|
| diff --git a/tools/android/forwarder2/forwarder.cc b/tools/android/forwarder2/forwarder.cc
|
| index fe9ddeee9fdd3339618215d64f82e0f80b277f5d..8ca25bb2b8e8441b2e34bb3829a9ecd7075d1ed7 100644
|
| --- a/tools/android/forwarder2/forwarder.cc
|
| +++ b/tools/android/forwarder2/forwarder.cc
|
| @@ -136,7 +136,13 @@ class Forwarder::BufferedCopier {
|
|
|
| // Call this after a select() call to operate over the buffer.
|
| void ProcessSelect(const fd_set& read_fds, const fd_set& write_fds) {
|
| - int fd, ret;
|
| + int fd;
|
| + int ret;
|
| + // With FORTIFY_SOURCE, FD_ISSET is implemented as a function that takes a
|
| + // non-const fd_set*. Make a copy of the passed arguments so we can safely
|
| + // take a reference.
|
| + fd_set read_fds_copy = read_fds;
|
| + fd_set write_fds_copy = write_fds;
|
| switch (state_) {
|
| case STATE_READING:
|
| fd = socket_from_->fd();
|
| @@ -144,7 +150,7 @@ class Forwarder::BufferedCopier {
|
| state_ = STATE_CLOSED; // T02
|
| return;
|
| }
|
| - if (!FD_ISSET(fd, &read_fds))
|
| + if (!FD_ISSET(fd, &read_fds_copy))
|
| return;
|
|
|
| ret = socket_from_->NonBlockingRead(buffer_, kBufferSize);
|
| @@ -164,7 +170,7 @@ class Forwarder::BufferedCopier {
|
| ForceClose(); // T06 + T11
|
| return;
|
| }
|
| - if (!FD_ISSET(fd, &write_fds))
|
| + if (!FD_ISSET(fd, &write_fds_copy))
|
| return;
|
|
|
| ret = socket_to_->NonBlockingWrite(buffer_ + write_offset_,
|
|
|