Changeset 464 for azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/src
- Timestamp:
- Jun 22, 2021, 9:00:19 PM (3 years ago)
- Location:
- azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/src/buffer.c
r457 r464 541 541 { 542 542 //put b2 ahead of b1: [b2][b1], return b1 543 if (b2->size == 0)543 if (b2->size == 0) 544 544 { 545 545 // do nothing 546 546 result = 0; 547 } 548 else if (b1->size + b2->size < b2->size) 549 { 550 LogError("Failure: size_t overflow."); 551 result = MU_FAILURE; 547 552 } 548 553 else -
azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/src/crt_abstractions.c
r457 r464 6 6 #include <stdlib.h> 7 7 #include <stdarg.h> 8 #include <stdint.h> 8 9 #include <string.h> 9 10 #include <limits.h> … … 598 599 case FST_NUMBER: 599 600 val = fraction * pow(10.0, (double)exponential) * (double)signal; 600 if ((val >= ( FLT_MAX * (-1.0f))) && (val <=FLT_MAX))601 if ((val >= ((double)FLT_MAX * (-1.0))) && (val <= (double)FLT_MAX)) 601 602 { 602 603 /*Codes_SRS_CRT_ABSTRACTIONS_21_016: [The strtof_s must return the float that represents the value in the initial part of the string. If any.]*/ … … 836 837 return result; 837 838 } 839 840 /*takes "value" and transforms it into a decimal string*/ 841 /*10 => "10"*/ 842 /*return 0 when everything went ok*/ 843 int uint64_tToString(char* destination, size_t destinationSize, uint64_t value) 844 { 845 int result; 846 size_t pos; 847 /*the below loop gets the number in reverse order*/ 848 if ( 849 (destination == NULL) || 850 (destinationSize < 2) /*because the smallest number is '0\0' which requires 2 characters*/ 851 ) 852 { 853 result = MU_FAILURE; 854 } 855 else 856 { 857 pos = 0; 858 do 859 { 860 destination[pos++] = '0' + (value % 10); 861 value /= 10; 862 } while ((value > 0) && (pos < (destinationSize - 1))); 863 864 if (value == 0) 865 { 866 size_t w; 867 destination[pos] = '\0'; 868 /*all converted and they fit*/ 869 for (w = 0; w <= (pos - 1) >> 1; w++) 870 { 871 char temp; 872 temp = destination[w]; 873 destination[w] = destination[pos - 1 - w]; 874 destination[pos - 1 - w] = temp; 875 } 876 result = 0; 877 } 878 else 879 { 880 result = MU_FAILURE; 881 } 882 } 883 return result; 884 } -
azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/src/httpapiexsas.c
r457 r464 107 107 { 108 108 /*Codes_SRS_HTTPAPIEXSAS_06_005: [If the parameter handle is NULL then HTTAPIEX_SAS_Destroy shall do nothing and return.]*/ 109 if (handle) 109 HTTPAPIEX_SAS_STATE* state = (HTTPAPIEX_SAS_STATE*)handle; 110 if (state) 110 111 { 111 HTTPAPIEX_SAS_STATE* state = (HTTPAPIEX_SAS_STATE*)handle;112 112 /*Codes_SRS_HTTPAPIEXSAS_06_006: [HTTAPIEX_SAS_Destroy shall deallocate any structures denoted by the parameter handle.]*/ 113 113 if (state->key) … … 159 159 /*Codes_SRS_HTTPAPIEXSAS_06_011: [SASToken_Create shall be invoked.]*/ 160 160 /*Codes_SRS_HTTPAPIEXSAS_06_012: [If the return result of SASToken_Create is NULL then fallthrough.]*/ 161 size_t expiry = (size_t)(difftime(currentTime, 0) + 3600);161 uint64_t expiry = (uint64_t)(difftime(currentTime, 0) + 3600); 162 162 newSASToken = SASToken_CreateString(state->key, state->uriResource, state->keyName, expiry); 163 163 } -
azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/src/sastoken.c
r457 r464 24 24 if (expiryASCII[i] >= '0' && expiryASCII[i] <= '9') 25 25 { 26 value = value * 10 + ( double)(expiryASCII[i] -'0');26 value = value * 10 + ((double)expiryASCII[i] - (double)'0'); 27 27 } 28 28 else … … 203 203 } 204 204 205 static STRING_HANDLE construct_sas_token(const char* key, const char* scope, const char* keyname, size_t expiry)205 static STRING_HANDLE construct_sas_token(const char* key, const char* scope, const char* keyname, uint64_t expiry) 206 206 { 207 207 STRING_HANDLE result; … … 221 221 { 222 222 /*Codes_SRS_SASTOKEN_06_026: [If the conversion to string form fails for any reason then SASToken_Create shall return NULL.]*/ 223 if ( size_tToString(tokenExpirationTime, sizeof(tokenExpirationTime), expiry) != 0)223 if (uint64_tToString(tokenExpirationTime, sizeof(tokenExpirationTime), expiry) != 0) 224 224 { 225 225 LogError("For some reason converting seconds to a string failed. No SAS can be generated."); … … 303 303 } 304 304 305 STRING_HANDLE SASToken_Create(STRING_HANDLE key, STRING_HANDLE scope, STRING_HANDLE keyName, size_t expiry)305 STRING_HANDLE SASToken_Create(STRING_HANDLE key, STRING_HANDLE scope, STRING_HANDLE keyName, uint64_t expiry) 306 306 { 307 307 STRING_HANDLE result; … … 326 326 } 327 327 328 STRING_HANDLE SASToken_CreateString(const char* key, const char* scope, const char* keyName, size_t expiry)328 STRING_HANDLE SASToken_CreateString(const char* key, const char* scope, const char* keyName, uint64_t expiry) 329 329 { 330 330 STRING_HANDLE result; -
azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/src/sha384-512.c
r457 r464 469 469 if (!length) 470 470 return shaSuccess; 471 472 if (length > (sizeof(context->Message_Block) / sizeof(context->Message_Block[0]))) 473 return shaBadParam; 471 474 472 475 if (!context || !message_array)
Note:
See TracChangeset
for help on using the changeset viewer.