trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DaveBirdsall <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request #541: Changes for converting commitId<->asc...
Date Mon, 13 Jun 2016 20:27:21 GMT
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/541#discussion_r66860910
  
    --- Diff: core/sqf/src/seatrans/tm/hbasetmlib2/idtm.cpp ---
    @@ -192,6 +192,89 @@ jint Java_org_apache_hadoop_hbase_regionserver_transactional_IdTm_native_1id(JNI
     }
     
     //
    +// org.apache.hadoop.hbase.regionserver.transactional.idTm.native_id_to_string(j_timeout,
j_id, j_id_string)
    +//
    +// initialize.
    +// call do_cli_id_to_string() and set j_id_to_string to formatted date/time from from
do_cli_id_to_string()
    +//
    +// return file error
    +//
    +jint Java_org_apache_hadoop_hbase_regionserver_transactional_IdTm_native_1id_1to_1string(JNIEnv
*pp_j_env, jobject, jint j_timeout, jlong j_id, jbyteArray j_id_string) {
    +    int      lv_ferr;
    +    unsigned long     lv_id;
    +    char     la_ascii_time[MAX_DATE_TIME_BUFF_LEN * 2];
    +    char*    output;
    +
    +    lv_ferr = do_init(pp_j_env);
    +    lv_id = (unsigned long)j_id;
    +
    +    if (lv_ferr == XZFIL_ERR_OK) {
    +        lv_ferr = do_cli_id_to_string(&gv_phandle, j_timeout, lv_id, la_ascii_time);
    +        if (lv_ferr == XZFIL_ERR_OK) {
    +           if(strlen(la_ascii_time) > MAX_DATE_TIME_BUFF_LEN) {
    +              if (gv_verbose)
    +                  printf("cli: id_to_string() output string is too long %s\n", la_ascii_time);
    +              return XZFIL_ERR_BUFTOOSMALL;
    +           }
    +           output = (char *) (pp_j_env)->GetByteArrayElements(j_id_string, NULL);
    +           strcpy(output, la_ascii_time);
    +           (pp_j_env)->ReleaseByteArrayElements(j_id_string, (jbyte *)output, 0);
    +        }
    +    }
    +    if (gv_verbose)
    +        printf("cli: id_to_string() err=%d, id=0x%lx id_string=%s\n", lv_ferr, lv_id,
la_ascii_time);
    +
    +    return lv_ferr;
    +}
    +
    +//
    +// org.apache.hadoop.hbase.regionserver.transactional.idTm.native_string_to_id(j_timeout,
j_id, j_id_string)
    +//
    +// initialize.
    +// call do_cli_string_to_id() and set j_id to value from formatted date/time supplied
as j_id_to_string
    +//
    +// return file error
    +//
    +jint Java_org_apache_hadoop_hbase_regionserver_transactional_IdTm_native_1string_1to_1id(JNIEnv
*pp_j_env, jobject, jint j_timeout, jobject j_id, jbyteArray j_id_string, jint j_len) {
    +    int            lv_ferr;
    +    int            len;
    +    unsigned long  lv_id = 0L;
    +    char           la_ascii_time[MAX_DATE_TIME_BUFF_LEN * 2];
    +    jbyte         *input;
    +    jclass         lv_id_class;
    +    jfieldID       lv_id_val;
    +
    +    lv_ferr = do_init(pp_j_env);
    +
    +    if (lv_ferr == XZFIL_ERR_OK) {
    +       len = (int) j_len;
    +       if (gv_verbose)
    +           printf("cli: string_to_id() len is %d\n", len);
    +       input = (pp_j_env)->GetByteArrayElements(j_id_string, NULL);
    +       memcpy(la_ascii_time,(char *)input, len);
    --- End diff --
    
    Are we guaranteed there will never be a buffer overflow? Or does this function simply
assume we won't?


---
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