| 1196 | } |
| 1197 | |
| 1198 | IOURINGINLINE struct io_uring_recvmsg_out * |
| 1199 | io_uring_recvmsg_validate(void *buf, int buf_len, struct msghdr *msgh) |
| 1200 | LIBURING_NOEXCEPT |
| 1201 | { |
| 1202 | unsigned long ulen = (unsigned long)(unsigned int)buf_len; |
| 1203 | unsigned long hdr = sizeof(struct io_uring_recvmsg_out); |
| 1204 | unsigned long namelen = msgh->msg_namelen; |
| 1205 | unsigned long controllen = msgh->msg_controllen; |
| 1206 | |
| 1207 | if (buf_len < 0 || ulen < hdr) |
| 1208 | return NULL; |
| 1209 | /* check each addition separately to avoid integer overflow */ |
| 1210 | if (namelen > ulen - hdr) |
| 1211 | return NULL; |
| 1212 | if (controllen > ulen - hdr - namelen) |
| 1213 | return NULL; |
| 1214 | return (struct io_uring_recvmsg_out *)buf; |
| 1215 | } |
| 1216 | |
| 1217 | IOURINGINLINE void *io_uring_recvmsg_name(struct io_uring_recvmsg_out *o) |
| 1218 | LIBURING_NOEXCEPT |
no outgoing calls