lib: xpc: fix overlapping variable uses in xpc_buffer_t

This commit is contained in:
2026-03-21 10:52:16 +00:00
parent aa155824d3
commit 81b9e7777a
2 changed files with 19 additions and 33 deletions

View File

@@ -52,14 +52,10 @@ kern_status_t xpc_buffer_write(
return KERN_OK;
}
kern_status_t status
= xpc_msg_write(buf->buf_origin, buf->buf_offset, in, to_write);
if (status != KERN_OK) {
return status;
}
/* TODO */
*nr_written = to_write;
return KERN_OK;
return xpc_msg_write(
buf->buf_origin,
buf->buf_offset,
in,
to_write,
nr_written);
}

View File

@@ -16,14 +16,13 @@
.buf_flags = XPC_BUFFER_F_OUT | XPC_BUFFER_F_REMOTE, \
.buf_origin = (msg), \
.buf_offset = (offset), \
.buf_len = (size), \
.buf_max = (size), \
}
#define XPC_LOCAL_BUFFER_OUT(ptr, size) \
{ \
.buf_flags = XPC_BUFFER_F_OUT, \
.buf_ptr = (ptr), \
.buf_max = (size), \
.buf_len = (size), \
}
struct xpc_msg;
@@ -46,27 +45,18 @@ typedef enum xpc_buffer_flags {
typedef struct xpc_buffer {
xpc_buffer_flags_t buf_flags;
union {
/* fields that are only valid if F_OUT is set */
struct {
/* only valid if F_OUT is set. specifies the maximum
* number of chars that can be written to buf_buf,
* including the null terminator. */
size_t buf_max;
/* only valid if F_OUT is set.
* if F_FREE_ON_DISCARD is set, must be either NULL or
* allocated via xpc_context_alloc */
void *buf_ptr;
};
/* fields that are only valid if F_IN is set */
struct {
/* only valid if F_IN is set. offset of the buffer data
* within the associated message. used when reading
* buffer data from a message. */
size_t buf_offset;
};
};
/* only valid if F_OUT is set. specifies the maximum
* number of chars that can be written to buf_buf,
* including the null terminator. */
size_t buf_max;
/* only valid if F_OUT is set.
* if F_FREE_ON_DISCARD is set, must be either NULL or
* allocated via xpc_context_alloc */
void *buf_ptr;
/* valid for F_IN and F_OUT. offset of the buffer data
* within the associated message. used when reading
* buffer data from a message. */
size_t buf_offset;
/* only valid if F_REMOTE is set.
* used to read/write buffer data from/to the sender's address