summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlawomir Mrozowicz <slawomirx.mrozowicz@intel.com>2017-09-20 10:20:24 +0200
committerThomas Monjalon <thomas@monjalon.net>2017-10-14 01:22:29 +0200
commitc874523dc9fc9c384a760eb5db8c6f295185e5e3 (patch)
tree27fe06fc5bdb265bd9bca0390f832344604068ff
parent72481c87ec80542cabf65fa8ad32ac381ee5ce4e (diff)
downloaddpdk-c874523dc9fc9c384a760eb5db8c6f295185e5e3.zip
dpdk-c874523dc9fc9c384a760eb5db8c6f295185e5e3.tar.gz
dpdk-c874523dc9fc9c384a760eb5db8c6f295185e5e3.tar.xz
examples/performance-thread: fix out-of-bounds tls array
Overrunning array per_lcore_this_sched->current_lthread->tls->data of 1024 8-byte elements at element index 1024 using index k. Fixed by correct check k condition. Coverity issue: 143462, 143463 Fixes: 116819b9ed0d ("examples/performance-thread: add lthread subsystem") Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com> Acked-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>
-rw-r--r--examples/performance-thread/common/lthread_tls.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/performance-thread/common/lthread_tls.c b/examples/performance-thread/common/lthread_tls.c
index 47505f2..56f0c2f 100644
--- a/examples/performance-thread/common/lthread_tls.c
+++ b/examples/performance-thread/common/lthread_tls.c
@@ -198,11 +198,12 @@ void _lthread_tls_destroy(struct lthread *lt)
void
*lthread_getspecific(unsigned int k)
{
+ void *res = NULL;
- if (k > LTHREAD_MAX_KEYS)
- return NULL;
+ if (k < LTHREAD_MAX_KEYS)
+ res = THIS_LTHREAD->tls->data[k];
- return THIS_LTHREAD->tls->data[k];
+ return res;
}
/*
@@ -212,7 +213,7 @@ void
*/
int lthread_setspecific(unsigned int k, const void *data)
{
- if (k > LTHREAD_MAX_KEYS)
+ if (k >= LTHREAD_MAX_KEYS)
return POSIX_ERRNO(EINVAL);
int n = THIS_LTHREAD->tls->nb_keys_inuse;