mirror of
https://salsa.debian.org/ha-team/libqb
synced 2026-01-08 21:13:58 +00:00
Feature: Enforce buffer size limits on the server side
This commit is contained in:
parent
9abb68637d
commit
9f6e4bb52d
@ -444,6 +444,18 @@ void qb_ipcs_connection_auth_set(qb_ipcs_connection_t *conn, uid_t uid,
|
||||
*/
|
||||
int32_t qb_ipcs_connection_get_buffer_size(qb_ipcs_connection_t *conn);
|
||||
|
||||
/**
|
||||
* Enforce the max buffer size clients must use from the server side.
|
||||
*
|
||||
* @note Setting this will force client connections to use at least
|
||||
* 'max_buf_size' bytes as their buffer size. If this value is not set
|
||||
* on the server, the clients enforce their own buffer sizes.
|
||||
*
|
||||
* @param ipc server instance
|
||||
* @param max buffer size in bytes
|
||||
*/
|
||||
void qb_ipcs_enforce_buffer_size(qb_ipcs_service_t *s, uint32_t max_buf_size);
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -133,6 +133,7 @@ struct qb_ipcs_funcs {
|
||||
struct qb_ipcs_service {
|
||||
enum qb_ipc_type type;
|
||||
char name[NAME_MAX];
|
||||
uint32_t max_buffer_size;
|
||||
int32_t service_id;
|
||||
int32_t ref_count;
|
||||
pid_t pid;
|
||||
|
||||
@ -455,9 +455,9 @@ handle_new_connection(struct qb_ipcs_service *s,
|
||||
return -ENOMEM;
|
||||
}
|
||||
c->setup.u.us.sock = sock;
|
||||
c->request.max_msg_size = req->max_msg_size;
|
||||
c->response.max_msg_size = req->max_msg_size;
|
||||
c->event.max_msg_size = req->max_msg_size;
|
||||
c->request.max_msg_size = QB_MAX(req->max_msg_size, s->max_buffer_size);
|
||||
c->response.max_msg_size = QB_MAX(req->max_msg_size, s->max_buffer_size);
|
||||
c->event.max_msg_size = QB_MAX(req->max_msg_size, s->max_buffer_size);
|
||||
c->pid = ugp->pid;
|
||||
c->auth.uid = c->euid = ugp->uid;
|
||||
c->auth.gid = c->egid = ugp->gid;
|
||||
|
||||
@ -954,3 +954,11 @@ qb_ipcs_connection_get_buffer_size(qb_ipcs_connection_t *c)
|
||||
* here. */
|
||||
return c->response.max_msg_size;
|
||||
}
|
||||
|
||||
void qb_ipcs_enforce_buffer_size(qb_ipcs_service_t *s, uint32_t buf_size)
|
||||
{
|
||||
if (s == NULL) {
|
||||
return;
|
||||
}
|
||||
s->max_buffer_size = buf_size;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user