From: samanway.dey@samsung.com Date: Thu, 23 May 2019 11:18:06 +0000 (+0530) Subject: Fixing crash in OCFillRandomMem (#512) X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F55%2F208355%2F1;p=platform%2Fupstream%2Fiotivity.git 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 --- 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;