protocol-native: fix out-of-bounds access to SEC_LABEL hex table

If buffer type char[] is 4-byte aligned, higher 3-byte on char could be non-zero if data is not initialized, which make 'buffer[i] >> 4' larger than 0x0f.
Use type uint8_t[] on SEC_LABEL buffer to fix it.
This commit is contained in:
Huang-Huang Bao 2021-03-21 19:58:02 +08:00 committed by Wim Taymans
parent 471fffe4a3
commit 3bce026d67

View file

@ -391,7 +391,7 @@ static const struct pw_protocol_native_connection_events server_conn_events = {
.need_flush = on_server_need_flush, .need_flush = on_server_need_flush,
}; };
static bool check_print(const char *buffer, int len) static bool check_print(const uint8_t *buffer, int len)
{ {
int i; int i;
while (len > 1 && buffer[len-1] == 0) while (len > 1 && buffer[len-1] == 0)
@ -414,7 +414,7 @@ static struct client_data *client_new(struct server *s, int fd)
#endif #endif
struct pw_context *context = protocol->context; struct pw_context *context = protocol->context;
struct pw_properties *props; struct pw_properties *props;
char buffer[1024]; uint8_t buffer[1024];
struct protocol_data *d = pw_protocol_get_user_data(protocol); struct protocol_data *d = pw_protocol_get_user_data(protocol);
int i, res; int i, res;