Commit 062a9aaf authored by bauerb's avatar bauerb Committed by Commit bot

Fix device_forwarder build with FORTIFY_SOURCE.

BUG=430039

Review URL: https://codereview.chromium.org/697393002

Cr-Commit-Position: refs/heads/master@{#302603}
parent 4fa867f0
...@@ -136,7 +136,13 @@ class Forwarder::BufferedCopier { ...@@ -136,7 +136,13 @@ class Forwarder::BufferedCopier {
// Call this after a select() call to operate over the buffer. // Call this after a select() call to operate over the buffer.
void ProcessSelect(const fd_set& read_fds, const fd_set& write_fds) { 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_) { switch (state_) {
case STATE_READING: case STATE_READING:
fd = socket_from_->fd(); fd = socket_from_->fd();
...@@ -144,7 +150,7 @@ class Forwarder::BufferedCopier { ...@@ -144,7 +150,7 @@ class Forwarder::BufferedCopier {
state_ = STATE_CLOSED; // T02 state_ = STATE_CLOSED; // T02
return; return;
} }
if (!FD_ISSET(fd, &read_fds)) if (!FD_ISSET(fd, &read_fds_copy))
return; return;
ret = socket_from_->NonBlockingRead(buffer_, kBufferSize); ret = socket_from_->NonBlockingRead(buffer_, kBufferSize);
...@@ -164,7 +170,7 @@ class Forwarder::BufferedCopier { ...@@ -164,7 +170,7 @@ class Forwarder::BufferedCopier {
ForceClose(); // T06 + T11 ForceClose(); // T06 + T11
return; return;
} }
if (!FD_ISSET(fd, &write_fds)) if (!FD_ISSET(fd, &write_fds_copy))
return; return;
ret = socket_to_->NonBlockingWrite(buffer_ + write_offset_, ret = socket_to_->NonBlockingWrite(buffer_ + write_offset_,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment