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_r140913298
  
    --- 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);
    +    pJsonReader->nestDepth = 0;
    +    pJsonReader->state = JSON_STATE_START;
    +    pJsonReader->errorCode = JSON_SUCCESS;
    +    pJsonReader->currentCharPtr = pJsonReader->buf;
    +
    +    return pJsonReader;
    +}
    +
    +JsonReaderError jsonMoveCurrentCharPtr(JsonReader *pJsonReader)
    +{
    +    if (pJsonReader->isBufReady) {
    +        ++pJsonReader->currentCharPtr;
    +    }
    +
    +    if (pJsonReader->currentCharPtr == pJsonReader->buf + pJsonReader->numberReadBuf)
{
    +        if ((pJsonReader->numberReadBuf = fread(pJsonReader->buf, sizeof(char),
JSON_PARSER_BUF_LEN, pJsonReader->jsonFile))) {
    +            pJsonReader->currentCharPtr = pJsonReader->buf;
    +            pJsonReader->isBufReady = true;
    +        }
    +        else {
    +            pJsonReader->errorCode = JSON_ERROR_PARSE_EOF;
    +        }
    +    }
    +
    +    if (*(pJsonReader->currentCharPtr) == '\n') {
    --- End diff --
    
    Might this reference the first byte past the end of the buffer in the case that line 62
was executed? If so that opens the possibility of a segmentation violation.


---

Mime
View raw message