aboutsummaryrefslogtreecommitdiff
path: root/src/nng.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-02-05 10:23:35 -0800
committerGarrett D'Amore <garrett@damore.org>2018-02-05 10:23:35 -0800
commit844ce972fed056e1c4e0517e43b814c62d68edce (patch)
treeadfa91e3f7188d268f3d081e80c14f7e8a609a87 /src/nng.c
parentb893f8ff1f96dde567fa6a75f4b15bf69e53d6f5 (diff)
downloadnng-844ce972fed056e1c4e0517e43b814c62d68edce.tar.gz
nng-844ce972fed056e1c4e0517e43b814c62d68edce.tar.bz2
nng-844ce972fed056e1c4e0517e43b814c62d68edce.zip
fixes #228 aio iov should have larger limits (dynamically allocated)
Diffstat (limited to 'src/nng.c')
-rw-r--r--src/nng.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/nng.c b/src/nng.c
index 92d19d87..6f710993 100644
--- a/src/nng.c
+++ b/src/nng.c
@@ -1086,8 +1086,22 @@ nng_aio_set_timeout(nng_aio *aio, nni_duration when)
}
int
-nng_aio_set_iov(nng_aio *aio, int niov, nng_iov *iov)
-{
+nng_aio_set_iov(nng_aio *aio, unsigned niov, const nng_iov *iov)
+{
+// We limit the niov to prevent user insanity. This is required
+// to avoid stack allocations that might smash the stack. The
+// assumption is that we can always put at least 1kB on the stack --
+// our nng_iov structures are 16B. Systems without stack allocation
+// get a smaller limit, because we use an automatic variable.
+#if defined(NNG_HAVE_ALLOCA) || defined(_WIN32)
+ if (niov > 64) {
+ return (NNG_EINVAL);
+ }
+#else
+ if (niov > 16) {
+ return (NNG_EINVAL);
+ }
+#endif
return (nni_aio_set_iov(aio, niov, iov));
}