summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPradeep Venkatasubbarao2013-12-19 06:45:30 -0600
committerPradeep Venkatasubbarao2014-01-03 23:14:00 -0600
commit89aba51d6a81c19c4ee5eeeb3b87ca00c04bc6bc (patch)
treea757ae7c7788eed3e83500df5f2a1866bd0df9fa
parent056af5f3dccb4c772d29ce7df6a6ac6384c441ed (diff)
downloadrepo-libdce-89aba51d6a81c19c4ee5eeeb3b87ca00c04bc6bc.tar.gz
repo-libdce-89aba51d6a81c19c4ee5eeeb3b87ca00c04bc6bc.tar.xz
repo-libdce-89aba51d6a81c19c4ee5eeeb3b87ca00c04bc6bc.zip
[Bug] Fix possible client count overflow
The number of existing clients already running was being incremented and then checked for maximum clients allowed. However in the error scenario i.e. when maximum allowed clients are already running and the new incoming client connection request was rejected the client count was incremented unconditionally and not rolled back to previous value thus resulting in possible overflow error. This patch fixes this erroneous case. Change-Id: I3e2b2bebfd025ba6a99b7ef838537d9716154ca4 Signed-off-by: Pradeep Venkatasubbarao <pradeepv@ti.com>
-rw-r--r--libdce.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libdce.c b/libdce.c
index 349b6ab..5cb0ec5 100644
--- a/libdce.c
+++ b/libdce.c
@@ -164,13 +164,15 @@ static int dce_ipc_init(int core)
164 164
165 DEBUG(" >> dce_ipc_init\n"); 165 DEBUG(" >> dce_ipc_init\n");
166 166
167 /* Create remote server insance */ 167 /*First check if maximum clients are already using ipc*/
168 __ClientCount[core]++; 168 if(__ClientCount[core] >= MAX_INSTANCES) {
169
170 if(__ClientCount[core] > MAX_INSTANCES) {
171 eError = DCE_EXDM_UNSUPPORTED; 169 eError = DCE_EXDM_UNSUPPORTED;
172 return (eError); 170 return (eError);
173 } 171 }
172
173 /* Create remote server insance */
174 __ClientCount[core]++;
175
174 if(__ClientCount[core] > 1) { 176 if(__ClientCount[core] > 1) {
175 goto EXIT; 177 goto EXIT;
176 } 178 }