msghdr.c: fix printing SCM_RIGHTS array
* msghdr.c (print_scm_rights): Do not print array elements outside bounds defined by struct cmsghdr.cmsg_len.
This commit is contained in:
parent
6c30aecaf3
commit
029d979767
16
msghdr.c
16
msghdr.c
@ -59,20 +59,20 @@ print_scm_rights(struct tcb *tcp, const void *cmsg_data,
|
|||||||
const size_t data_len)
|
const size_t data_len)
|
||||||
{
|
{
|
||||||
const int *fds = cmsg_data;
|
const int *fds = cmsg_data;
|
||||||
const char *end = (const char *) cmsg_data + data_len;
|
const size_t nfds = data_len / sizeof(*fds);
|
||||||
bool seen = false;
|
size_t i;
|
||||||
|
|
||||||
if (sizeof(*fds) > data_len)
|
if (!nfds)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tprints(", cmsg_data=[");
|
tprints(", cmsg_data=[");
|
||||||
while ((const char *) fds < end) {
|
|
||||||
if (seen)
|
for (i = 0; i < nfds; ++i) {
|
||||||
|
if (i)
|
||||||
tprints(", ");
|
tprints(", ");
|
||||||
else
|
printfd(tcp, fds[i]);
|
||||||
seen = true;
|
|
||||||
printfd(tcp, *fds++);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tprints("]");
|
tprints("]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user