From 70ecc09feb2fbddeee9f7d67300ef18458f40f0c Mon Sep 17 00:00:00 2001 From: Sukanya Rajkhowa Date: Tue, 29 Oct 2013 14:55:30 +0800 Subject: [PATCH] Add support for cdma dynamic address length. Get the address,sub address,Bearer with dynamic length in the data parcel, to avoid the OutOfBoundsException with the MAX macro. BUG=26856156 Change-Id: I1d7437143c1369d77791136b68e06088acd72937 --- ril/libril/ril.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ril/libril/ril.cpp b/ril/libril/ril.cpp index f241c90..adb91d8 100755 --- a/ril/libril/ril.cpp +++ b/ril/libril/ril.cpp @@ -1643,6 +1643,7 @@ static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) { uint8_t uct; status_t status; int32_t digitCount; + int32_t digitLimit; memset(&rcsw, 0, sizeof(rcsw)); @@ -1673,7 +1674,9 @@ static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) { status = p.read(&uct,sizeof(uct)); rcsw.message.sAddress.number_of_digits = (uint8_t) uct; - for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_ADDRESS_MAX; digitCount ++) { + digitLimit = MIN((rcsw.message.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); + + for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) { status = p.read(&uct,sizeof(uct)); rcsw.message.sAddress.digits[digitCount] = (uint8_t) uct; } @@ -1687,7 +1690,9 @@ static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) { status = p.read(&uct,sizeof(uct)); rcsw.message.sSubAddress.number_of_digits = (uint8_t) uct; - for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_SUBADDRESS_MAX; digitCount ++) { + digitLimit = MIN((rcsw.message.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); + + for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) { status = p.read(&uct,sizeof(uct)); rcsw.message.sSubAddress.digits[digitCount] = (uint8_t) uct; } @@ -1695,7 +1700,9 @@ static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) { status = p.readInt32(&t); rcsw.message.uBearerDataLen = (int) t; - for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_BEARER_DATA_MAX; digitCount ++) { + digitLimit = MIN((rcsw.message.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); + + for(digitCount = 0 ; digitCount < digitLimit; digitCount ++) { status = p.read(&uct, sizeof(uct)); rcsw.message.aBearerData[digitCount] = (uint8_t) uct; } -- 2.20.1