@@ -75,7 +75,7 @@ static void serial_write_callback(const struct iovec *iov, int iovlen,
static void serial_read_callback(int fd, uint32_t events, void *user_data)
{
struct serial *serial = user_data;
- static uint8_t buf[4096];
+ uint8_t buf[4096];
uint8_t *ptr = buf;
ssize_t len;
uint16_t count;
@@ -87,8 +87,7 @@ static void serial_read_callback(int fd, uint32_t events, void *user_data)
}
again:
- len = read(serial->fd, buf + serial->pkt_offset,
- sizeof(buf) - serial->pkt_offset);
+ len = read(serial->fd, buf, sizeof(buf));
if (len < 0) {
if (errno == EAGAIN)
goto again;
@@ -98,7 +97,7 @@ again:
if (!serial->btdev)
return;
- count = serial->pkt_offset + len;
+ count = len;
while (count > 0) {
hci_command_hdr *cmd_hdr;
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> This fixes the following build errors caused by buf being used as a static from tracking progress of a packet when it is not necessary since pkt_data exists for the same reason: /usr/include/bits/unistd.h:32:10: error: ‘__read_alias’ specified size between 18446744073709490177 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=] 32 | return __glibc_fortify (read, __nbytes, sizeof (char), | ^~~~~~~~~~~~~~~ emulator/serial.c: In function ‘serial_read_callback’: emulator/serial.c:78:24: note: destination object allocated here 78 | static uint8_t buf[4096]; | ^~~ /usr/include/bits/unistd-decl.h:29:16: note: in a call to function ‘__read_alias’ declared with attribute ‘access (write_only, 2, 3)’ 29 | extern ssize_t __REDIRECT_FORTIFY (__read_alias, (int __fd, void *__buf, | ^~~~~~~~~~~~~~~~~~ Fixes: https://github.com/bluez/bluez/issues/1049 --- emulator/serial.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)