[ 
https://issues.apache.org/jira/browse/TRAFODION-2229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15633648#comment-15633648
 ] 

ASF GitHub Bot commented on TRAFODION-2229:
-------------------------------------------

Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/813#discussion_r86404262
  
    --- Diff: core/sql/exp/exp_function.cpp ---
    @@ -7900,6 +7936,114 @@ ex_expr::exp_return_type 
ExFunctionInetNtoa::eval(char * op_data[],
        return ex_expr::EXPR_OK;
     }
     
    +ex_expr::exp_return_type ExFunctionCrc32::eval(char * op_data[],
    +                                                        CollHeap *heap,
    +                                                        ComDiagsArea 
**diags)
    +{
    +  Attributes *resultAttr   = getOperand(0);
    +  Attributes *srcAttr   = getOperand(1);
    +
    +  Lng32 slen = srcAttr->getLength(op_data[-MAX_OPERANDS+1]);
    +  Lng32 rlen = resultAttr->getLength();
    +
    +  *(ULng32*)op_data[0] = 0; 
    +  ULng32 crc = crc32(0L, Z_NULL, 0);
    +  crc = crc32 (crc, (const Bytef*)op_data[1], slen);
    +  *(ULng32*)op_data[0] = crc; 
    +  return ex_expr::EXPR_OK;
    +}
    +
    +//only support SHA 256 for this version
    +//TBD: add 224 and 384, 512 in next version
    +ex_expr::exp_return_type ExFunctionSha2::eval(char * op_data[],
    +                                                        CollHeap *heap,
    +                                                        ComDiagsArea 
**diags)
    +{
    +
    +  unsigned char sha[SHA256_DIGEST_LENGTH+ 1]={0};  
    +
    +  Attributes *resultAttr   = getOperand(0);
    +  Attributes *srcAttr   = getOperand(1);
    +
    +  Lng32 slen = srcAttr->getLength(op_data[-MAX_OPERANDS+1]);
    +  Lng32 rlen = resultAttr->getLength();
    +
    +  memset(op_data[0], 0, rlen);
    +
    +  SHA256_CTX  sha_ctx;
    +
    +  SHA256_Init(&sha_ctx);  
    +  SHA256_Update(&sha_ctx, op_data[1], slen);
    +  SHA256_Final((unsigned char*) sha,&sha_ctx); 
    +  char tmp[2];
    --- End diff --
    
    Looks too short. The sprintf will write three bytes (two digits + a null 
terminator), so it will overrun this buffer.


> add Hashing functions to Trafodion
> ----------------------------------
>
>                 Key: TRAFODION-2229
>                 URL: https://issues.apache.org/jira/browse/TRAFODION-2229
>             Project: Apache Trafodion
>          Issue Type: Sub-task
>            Reporter: liu ming
>            Assignee: liu ming
>
> CRC32()       Compute a cyclic redundancy check value
> MD5() Calculate MD5 checksum
> SHA1(), SHA() Calculate an SHA-1 160-bit checksum
> SHA2()        Calculate an SHA-2 checksum



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to