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 #1237: [TRAFODION-2726] odb support to load...
Date Mon, 25 Sep 2017 22:16:51 GMT
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/1237#discussion_r140911804
  
    --- Diff: core/conn/odb/src/JsonReader.c ---
    @@ -0,0 +1,563 @@
    +//------------------------------------------------------------------
    +//
    +// @@@ START COPYRIGHT @@@
    +//
    +// Licensed to the Apache Software Foundation (ASF) under one
    +// or more contributor license agreements.  See the NOTICE file
    +// distributed with this work for additional information
    +// regarding copyright ownership.  The ASF licenses this file
    +// to you under the Apache License, Version 2.0 (the
    +// "License"); you may not use this file except in compliance
    +// with the License.  You may obtain a copy of the License at
    +//
    +//   http://www.apache.org/licenses/LICENSE-2.0
    +//
    +// Unless required by applicable law or agreed to in writing,
    +// software distributed under the License is distributed on an
    +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +// KIND, either express or implied.  See the License for the
    +// specific language governing permissions and limitations
    +// under the License.
    +//
    +// @@@ END COPYRIGHT @@@
    +
    +#include "JsonReader.h"
    +#include <errno.h>
    +#include <string.h>
    +
    +JsonReader *jsonReaderNew(const char *path)
    +{
    +    JsonReader *pJsonReader = (JsonReader *)calloc(1, sizeof(JsonReader));
    +    if (!pJsonReader) {
    +        return NULL;
    +    }
    +
    +    pJsonReader->jsonFile = fopen(path, "r");
    +    if (!pJsonReader->jsonFile) {
    +        free(pJsonReader);
    +        return NULL;
    +    }
    +
    +    strncpy(pJsonReader->jsonFileName, path, JSON_PARSER_MAX_FILE_NAME_LEN);
    --- End diff --
    
    If the path is too long, there won't be a null terminator. To be safe, you may want to
set the last character in the buffer to the null character after the strncpy call.


---

Mime
View raw message