Skip to content

Commit

Permalink
Bug fix in cast to float with range checks
Browse files Browse the repository at this point in the history
  • Loading branch information
cpiker committed Oct 22, 2024
1 parent 13482fa commit d0f3311
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions das2/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,24 +1065,25 @@ static DasErrCode _swap_write(DasBuf* pBuf, const ubyte* pSrc, size_t uVals, int
return DAS_OKAY;
}

/* Encode helper: change widths with checks ******************************** */
/* Encode helper: change widths with checks and swap *********************** */

static DasErrCode _cast_write(
static DasErrCode _cast_swap_write(
DasBuf* pBuf, const ubyte* pSrc, size_t uVals, das_val_type vtAry,
const ubyte* pFillIn, das_val_type vtBuf, const ubyte* pFillOut
){

uint64_t outval;
uint64_t outswap;

size_t insize = das_vt_size(vtAry);
size_t outsize = das_vt_size(vtBuf);
assert(outsize <= 8);

ubyte* pIn = NULL;
ubyte* pOut = NULL;

int nRet;
for(size_t u = 0; u < (uVals); u += outsize){
for(size_t u = 0; u < (uVals*insize); u += insize){

nRet = das_value_binXform(
vtAry, pSrc + u, pFillIn,
Expand All @@ -1106,18 +1107,20 @@ static DasErrCode _cast_write(
return DAS_OKAY;
}

/* Encode helper: change widths with checks and swap *********************** */
/* Encode helper: change widths with checks ******************************** */

static DasErrCode _cast_swap_write(
static DasErrCode _cast_write(
DasBuf* pBuf, const ubyte* pSrc, size_t uVals, das_val_type vtAry,
const ubyte* pFillIn, das_val_type vtBuf, const ubyte* pFillOut
){

uint64_t outval;
size_t insize = das_vt_size(vtAry);
size_t outsize = das_vt_size(vtBuf);
assert(outsize <= 8);

int nRet;
for(size_t u = 0; u < (uVals); u += outsize){
for(size_t u = 0; u < (uVals*insize); u += insize){

nRet = das_value_binXform(
vtAry, pSrc + u, pFillIn,
Expand Down

0 comments on commit d0f3311

Please sign in to comment.