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

    https://github.com/apache/incubator-hawq/pull/1265#discussion_r126864478
  
    --- Diff: depends/libhdfs3/src/client/KmsClientProvider.cpp ---
    @@ -0,0 +1,318 @@
    +/********************************************************************
    + * 2014 -
    + * open source under Apache License Version 2.0
    + ********************************************************************/
    +/**
    + * 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.
    + */
    +
    +#include "KmsClientProvider.h"
    +#include "Logger.h"
    +#include <gsasl.h>
    +#include <map>
    +#include <boost/property_tree/json_parser.hpp>
    +using namespace Hdfs::Internal;
    +using boost::property_tree::read_json;
    +using boost::property_tree::write_json;
    +
    +namespace Hdfs {
    +
    +/**
    + * Convert ptree format to json format
    + */
    +std::string KmsClientProvider::toJson(const ptree &data)
    +{
    +   std::ostringstream buf;
    +   try {
    +           write_json(buf, data, false);
    +           std::string json = buf.str();
    +           return json;
    +   } catch (...) {
    +           THROW(HdfsIOException, "KmsClientProvider : Write json 
failed.");
    +   }       
    +}
    +
    +/**
    + * Convert json format to ptree format
    + */
    +ptree KmsClientProvider::fromJson(const std::string &data)
    +{
    +   ptree pt2;
    +   try {
    +           std::istringstream is(data);
    +           read_json(is, pt2);
    +           return pt2;
    +   } catch (...) {
    +           THROW(HdfsIOException, "KmsClientProvider : Read json failed.");
    +   }
    +}
    +
    +/**
    + * Encode string to base64. 
    + */
    +std::string        KmsClientProvider::base64Encode(const std::string &data)
    +{
    +   char * buffer = NULL;
    +   size_t len = 0;
    +   int rc = 0;
    +   std::string result;
    +
    +   LOG(DEBUG1, "KmsClientProvider : Encode data is %s", data.c_str());
    +
    +   if (GSASL_OK != (rc = gsasl_base64_to(data.c_str(), data.size(), 
&buffer, &len))) {
    --- End diff --
    
    Must use `data.data()` instead of `data.c_str()`, please check whether the 
similar issues existed in other place.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to