aboutsummaryrefslogtreecommitdiff
path: root/libseat/backend
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2020-09-07 23:33:50 +0200
committerKenny Levinsen <kl@kl.wtf>2020-09-07 23:35:24 +0200
commit047d8b284c285ad4b5a643511adb1d0ba8a4e63e (patch)
treeae91c5f46617db9b5f19a227856819725d828a9f /libseat/backend
parent1867f29d4274fec57876246f206bac620cf23828 (diff)
libseat: Handle SERVER_ERROR correctly
The connection buffer position was erroneously rewinded before reading the protocol message when the message was a SERVER_ERROR.
Diffstat (limited to 'libseat/backend')
-rw-r--r--libseat/backend/seatd.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/libseat/backend/seatd.c b/libseat/backend/seatd.c
index fd424b5..0b8064d 100644
--- a/libseat/backend/seatd.c
+++ b/libseat/backend/seatd.c
@@ -165,14 +165,13 @@ static size_t read_header(struct backend_seatd *backend, uint16_t expected_opcod
return SIZE_MAX;
}
if (header.opcode != expected_opcode) {
- connection_restore(&backend->connection, sizeof header);
struct proto_server_error msg;
if (header.opcode != SERVER_ERROR) {
log_errorf("Unexpected response: expected opcode %d, received opcode %d",
expected_opcode, header.opcode);
set_error(backend);
errno = EBADMSG;
- } else if (conn_get(backend, &msg, sizeof msg) == -1) {
+ } else if (header.size != sizeof msg || conn_get(backend, &msg, sizeof msg) == -1) {
set_error(backend);
errno = EBADMSG;
} else {