From a09da18c093b5303911cc4e3038298200450e9b1 Mon Sep 17 00:00:00 2001 From: "samanway.dey@samsung.com" Date: Thu, 23 May 2019 16:48:06 +0530 Subject: [PATCH] Fixing crash in OCFillRandomMem (#512) - In commit ca4adaec79350756d58b124af22bece9c3ad186d there was a bug which causes crash in IoTivity, fixed that https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/commit/c5711fd40dfbcaa3e47a6ac06ab08efd84ca66f2 (cherry picked from ca4adaec79350756d58b124af22bece9c3ad186d) Change-Id: I65d5e1ce3cd2a51ca9d0dd60b10158c9c97bbef7 Signed-off-by: Samanway Dey Signed-off-by: DoHyun Pyun --- resource/c_common/ocrandom/src/ocrandom.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resource/c_common/ocrandom/src/ocrandom.c b/resource/c_common/ocrandom/src/ocrandom.c index 97fe7be..babf32b 100644 --- a/resource/c_common/ocrandom/src/ocrandom.c +++ b/resource/c_common/ocrandom/src/ocrandom.c @@ -187,17 +187,18 @@ int8_t OCSeedRandom() void OCFillRandomMem(uint8_t * location, uint16_t len) { + int i, j, rand_idx; + i = len; if (!location) { return; } - for (; len--;) + for (; i--;) { *location++ = OCGetRandomByte(); } uint8_t *temp = (char *) OICCalloc(len, sizeof(char)); int *mask = (int *) OICCalloc(len, sizeof(int)); - int i, j, rand_idx; for (i = 0; i < len; i++) { mask[i] = 0; -- 2.7.4