- use free() instead of delete for c-string
- use strncpy instead of strcpy to be safe
Change-Id: I9ead030be37f5b000547a0beaf3d1f143fc58543
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
memset(&clientaddr, 0, sizeof(clientaddr));
clientaddr.sun_family = AF_UNIX;
- strcpy(clientaddr.sun_path, interface.c_str());
+ strncpy(clientaddr.sun_path, interface.c_str(), sizeof(clientaddr.sun_path) - 1);
int ret = TEMP_FAILURE_RETRY(
::connect(sock, (struct sockaddr *)&clientaddr, SUN_LEN(&clientaddr)));
#include <vector>
#include <memory>
#include <string>
+#include <functional>
#include <libintl.h>
#include <poll.h>
#include <sys/un.h>
namespace {
+using CstringPtr = std::unique_ptr<char, std::function<void(void*)>>;
+
struct TpkpPopup {
/* inputs */
std::string hostname;
return ECORE_CALLBACK_CANCEL;
}
-std::unique_ptr<char> getPopupContentString(TpkpPopup *pdp)
+CstringPtr getPopupContentString(TpkpPopup *pdp)
{
char *contentFormat = dgettext(PROJECT_NAME, "SID_CONTENT_PUBLIC_KEY_MISMATCHED");
char *content = nullptr;
TPKP_THROW_EXCEPTION(TPKP_E_MEMORY,
"Failed to alloc memory for popup text");
- return std::unique_ptr<char>(content);
+ return CstringPtr(content, free);
}
/*