Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1375)

Unified Diff: tools/android/forwarder2/forwarder.cc

Issue 697393002: Fix device_forwarder build with FORTIFY_SOURCE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698