projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
getservbyport_r: fix out-of-bounds buffer read
[musl]
/
src
/
aio
/
lio_listio.c
diff --git
a/src/aio/lio_listio.c
b/src/aio/lio_listio.c
index
8865029
..
a672812
100644
(file)
--- a/
src/aio/lio_listio.c
+++ b/
src/aio/lio_listio.c
@@
-1,5
+1,7
@@
#include <aio.h>
#include <errno.h>
#include <aio.h>
#include <errno.h>
+#include <unistd.h>
+#include <string.h>
#include "pthread_impl.h"
struct lio_state {
#include "pthread_impl.h"
struct lio_state {
@@
-10,7
+12,7
@@
struct lio_state {
static int lio_wait(struct lio_state *st)
{
static int lio_wait(struct lio_state *st)
{
- int i, err, got_err;
+ int i, err, got_err
= 0
;
int cnt = st->cnt;
struct aiocb **cbs = st->cbs;
int cnt = st->cnt;
struct aiocb **cbs = st->cbs;
@@
-30,7
+32,7
@@
static int lio_wait(struct lio_state *st)
}
return 0;
}
}
return 0;
}
- if (aio_suspend(cbs, cnt, 0))
+ if (aio_suspend(
(void *)
cbs, cnt, 0))
return -1;
}
}
return -1;
}
}
@@
-41,7
+43,7
@@
static void notify_signal(struct sigevent *sev)
.si_signo = sev->sigev_signo,
.si_value = sev->sigev_value,
.si_code = SI_ASYNCIO,
.si_signo = sev->sigev_signo,
.si_value = sev->sigev_value,
.si_code = SI_ASYNCIO,
- .si_pid =
__pthread_self()->pid
,
+ .si_pid =
getpid()
,
.si_uid = getuid()
};
__syscall(SYS_rt_sigqueueinfo, si.si_pid, si.si_signo, &si);
.si_uid = getuid()
};
__syscall(SYS_rt_sigqueueinfo, si.si_pid, si.si_signo, &si);
@@
-64,7
+66,7
@@
static void *wait_thread(void *p)
return 0;
}
return 0;
}
-int lio_listio(int mode, struct aiocb *
const cbs[], int cnt, struct sigevent *
sev)
+int lio_listio(int mode, struct aiocb *
restrict const *restrict cbs, int cnt, struct sigevent *restrict
sev)
{
int i, ret;
struct lio_state *st=0;
{
int i, ret;
struct lio_state *st=0;
@@
-81,7
+83,7
@@
int lio_listio(int mode, struct aiocb *const cbs[], int cnt, struct sigevent *se
}
st->cnt = cnt;
st->sev = sev;
}
st->cnt = cnt;
st->sev = sev;
- memcpy(st->cbs, cbs, cnt*sizeof *cbs);
+ memcpy(st->cbs,
(void*)
cbs, cnt*sizeof *cbs);
}
for (i=0; i<cnt; i++) {
}
for (i=0; i<cnt; i++) {
@@
-106,12
+108,12
@@
int lio_listio(int mode, struct aiocb *const cbs[], int cnt, struct sigevent *se
if (mode == LIO_WAIT) {
ret = lio_wait(st);
free(st);
if (mode == LIO_WAIT) {
ret = lio_wait(st);
free(st);
- return
0
;
+ return
ret
;
}
if (st) {
pthread_attr_t a;
}
if (st) {
pthread_attr_t a;
- sigset_t set;
+ sigset_t set
, set_old
;
pthread_t td;
if (sev->sigev_notify == SIGEV_THREAD) {
pthread_t td;
if (sev->sigev_notify == SIGEV_THREAD) {
@@
-126,15
+128,14
@@
int lio_listio(int mode, struct aiocb *const cbs[], int cnt, struct sigevent *se
}
pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED);
sigfillset(&set);
}
pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED);
sigfillset(&set);
- pthread_sigmask(SIG_BLOCK, &set, &set);
+ pthread_sigmask(SIG_BLOCK, &set, &set
_old
);
if (pthread_create(&td, &a, wait_thread, st)) {
free(st);
errno = EAGAIN;
return -1;
}
if (pthread_create(&td, &a, wait_thread, st)) {
free(st);
errno = EAGAIN;
return -1;
}
- pthread_sigmask(SIG_SETMASK, &set, 0);
+ pthread_sigmask(SIG_SETMASK, &set
_old
, 0);
}
return 0;
}
}
return 0;
}
-