Ignore:
Timestamp:
Jun 22, 2021, 9:00:19 PM (3 years ago)
Author:
coas-nagasima
Message:

WolfSSLとAzure IoT SDKを更新

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  
    541541        {
    542542            //put b2 ahead of b1: [b2][b1], return b1
    543             if (b2->size ==0)
     543            if (b2->size == 0)
    544544            {
    545545                // do nothing
    546546                result = 0;
     547            }
     548            else if (b1->size + b2->size < b2->size)
     549            {
     550                LogError("Failure: size_t overflow.");
     551                result = MU_FAILURE;
    547552            }
    548553            else
  • azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/src/crt_abstractions.c

    r457 r464  
    66#include <stdlib.h>
    77#include <stdarg.h>
     8#include <stdint.h>
    89#include <string.h>
    910#include <limits.h>
     
    598599        case FST_NUMBER:
    599600            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))
    601602            {
    602603                /*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.]*/
     
    836837    return result;
    837838}
     839
     840/*takes "value" and transforms it into a decimal string*/
     841/*10 => "10"*/
     842/*return 0 when everything went ok*/
     843int 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  
    107107{
    108108    /*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)
    110111    {
    111         HTTPAPIEX_SAS_STATE* state = (HTTPAPIEX_SAS_STATE*)handle;
    112112        /*Codes_SRS_HTTPAPIEXSAS_06_006: [HTTAPIEX_SAS_Destroy shall deallocate any structures denoted by the parameter handle.]*/
    113113        if (state->key)
     
    159159                        /*Codes_SRS_HTTPAPIEXSAS_06_011: [SASToken_Create shall be invoked.]*/
    160160                        /*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);
    162162                        newSASToken = SASToken_CreateString(state->key, state->uriResource, state->keyName, expiry);
    163163                    }
  • azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/src/sastoken.c

    r457 r464  
    2424        if (expiryASCII[i] >= '0' && expiryASCII[i] <= '9')
    2525        {
    26             value = value * 10 + (double)(expiryASCII[i] - '0');
     26            value = value * 10 + ((double)expiryASCII[i] - (double)'0');
    2727        }
    2828        else
     
    203203}
    204204
    205 static STRING_HANDLE construct_sas_token(const char* key, const char* scope, const char* keyname, size_t expiry)
     205static STRING_HANDLE construct_sas_token(const char* key, const char* scope, const char* keyname, uint64_t expiry)
    206206{
    207207    STRING_HANDLE result;
     
    221221    {
    222222        /*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)
    224224        {
    225225            LogError("For some reason converting seconds to a string failed.  No SAS can be generated.");
     
    303303}
    304304
    305 STRING_HANDLE SASToken_Create(STRING_HANDLE key, STRING_HANDLE scope, STRING_HANDLE keyName, size_t expiry)
     305STRING_HANDLE SASToken_Create(STRING_HANDLE key, STRING_HANDLE scope, STRING_HANDLE keyName, uint64_t expiry)
    306306{
    307307    STRING_HANDLE result;
     
    326326}
    327327
    328 STRING_HANDLE SASToken_CreateString(const char* key, const char* scope, const char* keyName, size_t expiry)
     328STRING_HANDLE SASToken_CreateString(const char* key, const char* scope, const char* keyName, uint64_t expiry)
    329329{
    330330    STRING_HANDLE result;
  • azure_iot_hub_f767zi/trunk/azure_iot_sdk/c-utility/src/sha384-512.c

    r457 r464  
    469469    if (!length)
    470470        return shaSuccess;
     471   
     472    if (length > (sizeof(context->Message_Block) / sizeof(context->Message_Block[0])))
     473        return shaBadParam;
    471474
    472475    if (!context || !message_array)
Note: See TracChangeset for help on using the changeset viewer.