lib: xpc: fix overlapping variable uses in xpc_string_t
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
.s_flags = XPC_STRING_F_OUT | XPC_STRING_F_REMOTE, \
|
.s_flags = XPC_STRING_F_OUT | XPC_STRING_F_REMOTE, \
|
||||||
.s_origin = (msg), \
|
.s_origin = (msg), \
|
||||||
.s_offset = (offset), \
|
.s_offset = (offset), \
|
||||||
.s_len = (size), \
|
.s_max = (size), \
|
||||||
}
|
}
|
||||||
|
|
||||||
struct xpc_msg;
|
struct xpc_msg;
|
||||||
@@ -41,25 +41,19 @@ typedef enum xpc_string_flags {
|
|||||||
|
|
||||||
typedef struct xpc_string {
|
typedef struct xpc_string {
|
||||||
xpc_string_flags_t s_flags;
|
xpc_string_flags_t s_flags;
|
||||||
union {
|
/* only valid if F_OUT is set. specifies the maximum
|
||||||
struct {
|
* number of chars that can be written to s_buf,
|
||||||
/* only valid if F_OUT is set. specifies the maximum
|
* including the null terminator. */
|
||||||
* number of chars that can be written to s_buf,
|
size_t s_max;
|
||||||
* including the null terminator. */
|
/* only valid if F_OUT is set.
|
||||||
size_t s_max;
|
* if F_FREE_ON_DISCARD is set, must be either NULL or
|
||||||
/* only valid if F_OUT is set.
|
* allocated via xpc_context_alloc */
|
||||||
* if F_FREE_ON_DISCARD is set, must be either NULL or
|
const char *s_buf;
|
||||||
* allocated via xpc_context_alloc */
|
|
||||||
const char *s_buf;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct {
|
/* valid for F_IN and F_OUT. offset of the string data
|
||||||
/* only valid if F_IN is set. offset of the string data
|
* within the associated message. used when reading
|
||||||
* within the associated message. used when reading
|
* string data from a message. */
|
||||||
* string data from a message. */
|
size_t s_offset;
|
||||||
size_t s_offset;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/* only valid if F_REMOTE is set.
|
/* only valid if F_REMOTE is set.
|
||||||
* used to read/write string data from/to the sender's address space. */
|
* used to read/write string data from/to the sender's address space. */
|
||||||
|
|||||||
@@ -47,14 +47,10 @@ xpc_status_t xpc_string_write(
|
|||||||
to_write = s->s_max - 1;
|
to_write = s->s_max - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
kern_status_t status
|
return xpc_msg_write(
|
||||||
= xpc_msg_write(s->s_origin, s->s_offset, in, to_write);
|
s->s_origin,
|
||||||
if (status != KERN_OK) {
|
s->s_offset,
|
||||||
return status;
|
in,
|
||||||
}
|
to_write,
|
||||||
|
nr_written);
|
||||||
/* TODO */
|
|
||||||
*nr_written = to_write;
|
|
||||||
|
|
||||||
return KERN_OK;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user