ceph/src/rgw/rgw_rest_config.h
Danny Al-Gaaf e910421719 rgw: change RGWOp::name() to return string instead of char*
Return 'const string' instead of 'const char *' from RGWOp::name() to
avoid the usage of std::string:c_str() to return 'const char *' in
some cases in rgw_rest_replica_log.h.

Returning result of c_str() from a function is dangerous since the
result gets (may) invalid after the related string object gets
destroyed or out of scope (which is the case with return). So you
may end up with garbage in this case.

Related warning from cppcheck:
 [src/rgw/rgw_rest_replica_log.h:39]: (error) Dangerous usage of
  c_str(). The value returned by c_str() is invalid after this call.
 [src/rgw/rgw_rest_replica_log.h:59]: (error) Dangerous usage of
  c_str(). The value returned by c_str() is invalid after this call.
 [src/rgw/rgw_rest_replica_log.h:79]: (error) Dangerous usage of
  c_str(). The value returned by c_str() is invalid after this call

This should also fix:

CID 1049250 (#1 of 1): Wrapper object use after free (WRAPPER_ESCAPE)
  escape: The internal representation of "s" escapes, but is destroyed
  when it exits scope.
CID 1049251 (#1 of 1): Wrapper object use after free (WRAPPER_ESCAPE)
  escape: The internal representation of "s" escapes, but is destroyed
  when it exits scope.
CID 1049252 (#1 of 1): Wrapper object use after free (WRAPPER_ESCAPE)
  escape: The internal representation of "s" escapes, but is destroyed
  when it exits scope.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-07-20 19:02:18 +02:00

56 lines
1.2 KiB
C++

// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_RGW_REST_CONFIG_H
#define CEPH_RGW_REST_CONFIG_H
class RGWOp_RegionMap_Get : public RGWRESTOp {
RGWRegionMap regionmap;
public:
RGWOp_RegionMap_Get() {}
~RGWOp_RegionMap_Get() {}
int verify_permission() {
return 0;
}
void execute();
virtual void send_response();
virtual const string name() {
return "get_region_map";
}
};
class RGWHandler_Config : public RGWHandler_Auth_S3 {
protected:
RGWOp *op_get();
int read_permissions(RGWOp*) {
return 0;
}
public:
RGWHandler_Config() : RGWHandler_Auth_S3() {}
virtual ~RGWHandler_Config() {}
};
class RGWRESTMgr_Config : public RGWRESTMgr {
public:
RGWRESTMgr_Config() {}
virtual ~RGWRESTMgr_Config() {}
virtual RGWHandler *get_handler(struct req_state *s){
return new RGWHandler_Config;
}
};
#endif