mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-02-15 02:10:27 +01:00
brei: change the various errors to PROTOCOL
This commit is contained in:
parent
cc7a8cb95e
commit
a6565fd86b
1 changed files with 6 additions and 6 deletions
|
|
@ -168,7 +168,7 @@ brei_demarshal(struct brei_context *brei, struct iobuf *buf, const char *signatu
|
|||
{
|
||||
size_t nargs = strlen(signature);
|
||||
if (nargs > 256) {
|
||||
return brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_ERROR,
|
||||
return brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_PROTOCOL,
|
||||
"Too many arguments in signature (%zu)", nargs);
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ brei_demarshal(struct brei_context *brei, struct iobuf *buf, const char *signatu
|
|||
|
||||
uint32_t slen32 = bytes_to_int32(slen);
|
||||
if (end - p < slen32) {
|
||||
return brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_ERROR,
|
||||
return brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_PROTOCOL,
|
||||
"Invalid string length %zu, only %li bytes remaining", slen, (end - p) * 4);
|
||||
}
|
||||
|
||||
|
|
@ -210,7 +210,7 @@ brei_demarshal(struct brei_context *brei, struct iobuf *buf, const char *signatu
|
|||
|
||||
/* strings must be null-terminated */
|
||||
if (slen && str[slen - 1] != '\0') {
|
||||
return brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_ERROR,
|
||||
return brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_PROTOCOL,
|
||||
"Message string not zero-terminated");
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ brei_demarshal(struct brei_context *brei, struct iobuf *buf, const char *signatu
|
|||
break;
|
||||
}
|
||||
default:
|
||||
return brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_ERROR,
|
||||
return brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_PROTOCOL,
|
||||
"Invalid signature '%c'", *s);
|
||||
}
|
||||
arg++;
|
||||
|
|
@ -277,7 +277,7 @@ brei_marshal(struct brei_context *brei, struct iobuf *buf, const char *signature
|
|||
break;
|
||||
}
|
||||
default:
|
||||
return brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_ERROR,
|
||||
return brei_result_new(BREI_CONNECTION_DISCONNECT_REASON_PROTOCOL,
|
||||
"Invalid signature '%c'", *s);
|
||||
}
|
||||
s++;
|
||||
|
|
@ -470,7 +470,7 @@ MUNIT_TEST(test_brei_marshal_bad_sig)
|
|||
_unref_(brei_result) *result = brei_demarshal(brei, buf, "nxoiusf", &nargs, &args);
|
||||
munit_assert_ptr_not_null(result);
|
||||
munit_assert_int(brei_result_get_reason(result), ==,
|
||||
BREI_CONNECTION_DISCONNECT_REASON_ERROR);
|
||||
BREI_CONNECTION_DISCONNECT_REASON_PROTOCOL);
|
||||
munit_assert_int(nargs, ==, 789); /* nargs must not be touched on error */
|
||||
|
||||
return MUNIT_OK;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue