From: Jay Sharma Date: Mon, 28 Mar 2016 11:27:00 +0000 (+0530) Subject: [Resource-Encapsulation] [IOT-1026] Fixed Jira Issue X-Git-Tag: 1.2.0+RC1~426 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8a06c3620bff860d938d02fa0e0532fc56835b74;p=platform%2Fupstream%2Fiotivity.git [Resource-Encapsulation] [IOT-1026] Fixed Jira Issue Change-Id: I216c46097a85590ba927fe74c56b74b848a5611f Signed-off-by: Jay Sharma Reviewed-on: https://gerrit.iotivity.org/gerrit/6293 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi (cherry picked from commit c055363558b594263a523f54d5016463d64eb872) Reviewed-on: https://gerrit.iotivity.org/gerrit/7679 --- diff --git a/service/resource-encapsulation/examples/tizen/RESampleClientApp/src/reclient.cpp b/service/resource-encapsulation/examples/tizen/RESampleClientApp/src/reclient.cpp index 8761e1d..e344056 100644 --- a/service/resource-encapsulation/examples/tizen/RESampleClientApp/src/reclient.cpp +++ b/service/resource-encapsulation/examples/tizen/RESampleClientApp/src/reclient.cpp @@ -538,27 +538,69 @@ popup_set_clicked_cb(void *data, Evas_Object *obj, void *event_info) const char *attributeString = elm_entry_entry_get(entry); // Remove white spaces(if any) at the beginning int beginning = 0; + int negative = 0; + int invalidflag = 0; + while (attributeString[beginning] == ' ') { (beginning)++; } int len = strlen(attributeString); - if (NULL == attributeString || 1 > len) + + if((len >= 1) && ( '-' == attributeString[0])) + { + negative = 1; + } + + if(((len > 3) && negative) || (len > 2 && (!negative)) || (len==1 && negative)) { - dlog_print(DLOG_INFO, LOG_TAG, "#### Read NULL attribute Value"); - string logMessage = g_attributeKey + " Cannot be NULL
"; + invalidFlag = 1; + dlog_print(DLOG_INFO, LOG_TAG, "#### Not in allowed Range [-99 to 99]"); + string logMessage = g_attributeKey + " Not in allowed Range [-99 to 99]
"; logMessage += "----------------------
"; dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str()); - ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, &logMessage); + ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, + &logMessage); } else { + if (NULL == attributeString || 1 > len) + { + invalidFlag = 1; + dlog_print(DLOG_INFO, LOG_TAG, "#### Read NULL attribute Value"); + string logMessage = g_attributeKey + " Cannot be NULL
"; + logMessage += "----------------------
"; + dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str()); + ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, + &logMessage); + } + else + { + int i = 0; + while(i < len) + { + if(attributeString[i] < '0' || attributeString[i] > '9') + { + invalidFlag = 1; + dlog_print(DLOG_INFO, LOG_TAG, "#### Read invalid attribute Value"); + string logMessage = g_attributeKey + " Invalid charaters in input
"; + logMessage += "----------------------
"; + dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str()); + ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog, + &logMessage); + } + i++; + } + } + } + + if(invalidFlag != 1) + { int attributeValue = atoi(attributeString); string attrString(attributeString); setAttributeToRemoteServer(attributeValue); dlog_print(DLOG_INFO, LOG_TAG, "#### Attribute to set : %d", attributeValue); - string logMessage = g_attributeKey + " to set : " + attrString + "
"; logMessage += "----------------------
"; dlog_print(DLOG_INFO, LOG_TAG, " %s", logMessage.c_str());