Skip to content

Commit b610811

Browse files
authored
Unrolled build for #150986
Rollup merge of #150986 - bishop-fix-read, r=ChrisDenton std: Fix size returned by UEFI tcp4 read operations The read and read_vectored methods were returning the length of the input buffer, rather than the number of bytes actually read. Fix by changing read_inner to return the correct value, and have both read and read_vectored return that.
2 parents 1377169 + 6348105 commit b610811

File tree

1 file changed

+5
-4
lines changed
  • library/std/src/sys/net/connection/uefi

1 file changed

+5
-4
lines changed

library/std/src/sys/net/connection/uefi/tcp4.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl Tcp4 {
248248
fragment_table: [fragment],
249249
};
250250

251-
self.read_inner((&raw mut rx_data).cast(), timeout).map(|_| data_len as usize)
251+
self.read_inner((&raw mut rx_data).cast(), timeout)
252252
}
253253

254254
pub(crate) fn read_vectored(
@@ -288,14 +288,14 @@ impl Tcp4 {
288288
);
289289
};
290290

291-
self.read_inner(rx_data.as_mut_ptr(), timeout).map(|_| data_length as usize)
291+
self.read_inner(rx_data.as_mut_ptr(), timeout)
292292
}
293293

294294
pub(crate) fn read_inner(
295295
&self,
296296
rx_data: *mut tcp4::ReceiveData,
297297
timeout: Option<Duration>,
298-
) -> io::Result<()> {
298+
) -> io::Result<usize> {
299299
let evt = unsafe { self.create_evt() }?;
300300
let completion_token =
301301
tcp4::CompletionToken { event: evt.as_ptr(), status: Status::SUCCESS };
@@ -313,7 +313,8 @@ impl Tcp4 {
313313
if completion_token.status.is_error() {
314314
Err(io::Error::from_raw_os_error(completion_token.status.as_usize()))
315315
} else {
316-
Ok(())
316+
let data_length = unsafe { (*rx_data).data_length };
317+
Ok(data_length as usize)
317318
}
318319
}
319320

0 commit comments

Comments
 (0)