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; return KERN_OK;
} }
kern_status_t status return xpc_msg_write(
= xpc_msg_write(buf->buf_origin, buf->buf_offset, in, to_write); buf->buf_origin,
if (status != KERN_OK) { buf->buf_offset,
return status; in,
} to_write,
nr_written);
/* TODO */
*nr_written = to_write;
return KERN_OK;
} }

View File

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