diff --git a/src/at.c b/src/at.c index ee99ff4..56dbe76 100644 --- a/src/at.c +++ b/src/at.c @@ -245,7 +245,14 @@ static gboolean modem_response(gint fd, */ do { ret = read(fd, tmp, sizeof(tmp)); + if (ret > 0) { + /* If we're going to overflow truncate the data we read to fit */ + if (pos + ret >= sizeof(response)) { + g_critical("AT response buffer full, truncating"); + ret = sizeof(response) - (pos + 1); + } + memcpy(&response[pos], tmp, ret); pos += ret; usleep(10000);