diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-04-04 11:07:56 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-04-04 11:07:56 -0700 |
| commit | 505a9bce029e51540739c853a6c9eef0ecfb2e90 (patch) | |
| tree | d907679b6ab99bcb5da919db3d005d4976590c21 /src/transport/tcp | |
| parent | 0aa1de1316b46bb4af23fdf26759bca08008eaf5 (diff) | |
| download | nng-505a9bce029e51540739c853a6c9eef0ecfb2e90.tar.gz nng-505a9bce029e51540739c853a6c9eef0ecfb2e90.tar.bz2 nng-505a9bce029e51540739c853a6c9eef0ecfb2e90.zip | |
fixes #329 type checking not done for setopt
Diffstat (limited to 'src/transport/tcp')
| -rw-r--r-- | src/transport/tcp/tcp.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c index 9db5b016..80b372e9 100644 --- a/src/transport/tcp/tcp.c +++ b/src/transport/tcp/tcp.c @@ -760,13 +760,16 @@ nni_tcp_ep_connect(void *arg, nni_aio *aio) } static int -nni_tcp_ep_setopt_recvmaxsz(void *arg, const void *v, size_t sz) +nni_tcp_ep_setopt_recvmaxsz(void *arg, const void *v, size_t sz, int typ) { nni_tcp_ep *ep = arg; - if (ep == NULL) { - return (nni_chkopt_size(v, sz, 0, NNI_MAXSZ)); + size_t val; + int rv; + rv = nni_copyin_size(&val, v, sz, 0, NNI_MAXSZ, typ); + if ((rv == 0) && (ep != NULL)) { + ep->rcvmax = val; } - return (nni_setopt_size(&ep->rcvmax, v, sz, 0, NNI_MAXSZ)); + return (rv); } static int @@ -793,13 +796,16 @@ nni_tcp_ep_getopt_recvmaxsz(void *arg, void *v, size_t *szp, int typ) } static int -nni_tcp_ep_setopt_linger(void *arg, const void *v, size_t sz) +nni_tcp_ep_setopt_linger(void *arg, const void *v, size_t sz, int typ) { - nni_tcp_ep *ep = arg; - if (ep == NULL) { - return (nni_chkopt_ms(v, sz)); + nni_tcp_ep * ep = arg; + nng_duration val; + int rv; + + if (((rv = nni_copyin_ms(&val, v, sz, typ)) == 0) && (ep != NULL)) { + ep->linger = val; } - return (nni_setopt_ms(&ep->linger, v, sz)); + return (rv); } static int |
