trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arvind-narain <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request #799: [TRAFODION-2308]JDBC T4 support read ...
Date Thu, 03 Nov 2016 20:02:47 GMT
Github user arvind-narain commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/799#discussion_r86425694
  
    --- Diff: core/conn/odbc/src/odbc/nsksrvr/Interface/marshalingsrvr_srvr.cpp ---
    @@ -2300,3 +2300,89 @@ MxoSrvr_ValidateToken_param_res_(
     	return CEE_SUCCESS;
     
     } // MxoSrvr_ValidateToken_param_res_()
    +
    +CEE_status
    +odbc_SQLsrvr_ExtractLob_param_res_(
    +        CInterface * pnode
    +      , char* &buffer
    +      , UInt32& message_length
    +      , const struct odbc_SQLsrvr_ExtractLob_exc_ *exception_
    +      , IDL_long_long lobDataLen
    +      , IDL_char * lobDataValue
    +)
    +{
    +    IDL_long wlength = 0;
    +    char* curptr;
    +
    +    IDL_long exceptionLength = 0;
    +    wlength += sizeof(HEADER);
    +
    +    // calculate length of the buffer for each parameter
    +
    +    // length of odbc_SQLsrvr_ExtractLob_exc_
    +    wlength += sizeof(exception_->exception_nr);
    +    wlength += sizeof(exception_->exception_detail);
    +
    +    switch(exception_->exception_nr)
    +    {
    +        case odbc_SQLsrvr_ExtractLob_ParamError_exn_:
    +            wlength += sizeof(exceptionLength);
    +            if (exception_->u.ParamError.ParamDesc != NULL)
    +            {
    +                exceptionLength = strlen(exception_->u.ParamError.ParamDesc) + 1;
    +                wlength += exceptionLength;
    +            }
    +            break;
    +        case odbc_SQLSrvr_ExtractLob_SQLError_exn_:
    +            ERROR_DESC_LIST_length((ERROR_DESC_LIST_def *)&exception_->u.SQLError.errorList,
wlength);
    +            break;
    +        case odbc_SQLsrvr_ExtractLob_InvalidConnection_exn_:
    +        case odbc_SQLSrvr_ExtractLob_SQLInvalidhandle_exn_:
    +            break;
    +        default:
    +            break;
    +    }
    +
    +    // length of IDL_long  LOB len
    +    wlength += sizeof(IDL_long);
    +    if (lobDataValue != NULL)
    +    {
    +        wlength += lobDataLen;
    +    }
    +    wlength += lobDataLen;
    +
    +    // update the length of message
    +    message_length = wlength;
    +
    +    buffer = pnode->w_allocate(message_length);
    +    curptr = (IDL_char*)(buffer + sizeof(HEADER));
    +
    +    // copy odbc_SQLsrvr_ExtractLob_exc_
    +    IDL_long_copy((IDL_long *)&exception_->exception_nr, curptr);
    +    IDL_long_copy((IDL_long *)&exception_->exception_detail, curptr);
    +
    +    switch(exception_->exception_nr)
    +    {
    +        case odbc_SQLsrvr_ExtractLob_ParamError_exn_:
    +            IDL_long_copy(&exceptionLength, curptr);
    +            if (exception_->u.ParamError.ParamDesc != NULL)
    +                IDL_charArray_copy((const IDL_char *)exception_->u.ParamError.ParamDesc,
curptr);
    +            break;
    +
    +        case odbc_SQLSrvr_ExtractLob_SQLError_exn_:
    +            ERROR_DESC_LIST_copy((ERROR_DESC_LIST_def *)&exception_->u.SQLError.errorList,
curptr);
    +            break;
    +
    +        case odbc_SQLsrvr_ExtractLob_InvalidConnection_exn_:
    +        case odbc_SQLSrvr_ExtractLob_SQLInvalidhandle_exn_:
    +            break;
    +
    +        default:
    +            break;
    +    }
    +    IDL_long_copy((IDL_long *)&lobDataLen, curptr);
    --- End diff --
    
    At this point you could check for buffer overflow ( currptr > buffer + message_length
)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message