)
TARGET_LINK_LIBRARIES(${TARGET_ASKUSER_POPUP}
+ ${TARGET_ASKUSER_COMMON}
${ASKUSER_POPUP_DEP_LIBRARIES}
-pie
)
#include <Elementary.h>
#include <log/alog.h>
+#include <util/SafeFunction.h>
#include "popup.h"
#include "popup-runner.h"
#include "serialization.h"
using namespace AskUser::Agent;
+using namespace AskUser::Util;
namespace { // anonymous
if (ret < 0) {
int erryes = errno;
- ALOGE("sprintf failed with error: <" << strerror(erryes) << ">");
+ ALOGE("sprintf failed with error: <" << safeStrError(erryes) << ">");
return false;
}
close(pipe_in);
close(pipe_out);
ALOGE("read returned a negative value (" << count << ")");
- ALOGE("errno: " << strerror(errno));
+ ALOGE("errno: " << safeStrError(errno));
ALOGE("Exit popup - ERROR");
return popup_status::EXIT_ERROR;
}
#include <log/alog.h>
#include <ui/popup-runner.h>
#include <ui/AskUIPopupBackend.h>
+#include <util/SafeFunction.h>
namespace { // anonymous
using namespace AskUser::Agent;
+using namespace AskUser::Util;
std::string response_to_str(UIResponseType response) {
switch (response) {
tmp = TEMP_FAILURE_RETRY(read(m_fd_send_to_parent, result + count, buff_size - count));
if (tmp < 0) {
ALOGE("Error while reading popup response, read returned: " << tmp);
- ALOGE("errno: " << strerror(errno));
+ ALOGE("errno: " << safeStrError(errno));
goto error;
}
if (tmp > 0) {
SET(COMMON_SOURCES
${COMMON_PATH}/translator/Translator.cpp
${COMMON_PATH}/types/AgentErrorMsg.cpp
+ ${COMMON_PATH}/util/SafeFunction.cpp
)
ADD_DEFINITIONS("-fvisibility=default")
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Yunjin Lee <yunjin-.lee@samsung.com>
+ *
+ * Licensed 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.
+ */
+/**
+ * @file SafeFunction.cpp
+ * @author Yunjin Lee <yunjin-.lee@samsung.com>
+ * @version 1.0
+ * @brief Util for safe function.
+ */
+
+#include "SafeFunction.h"
+#include <string.h>
+#include <errno.h>
+
+namespace AskUser {
+namespace Util {
+#define ERROR_STRING_SIZE 256
+
+std::string safeStrError(int error) {
+ char buf[ERROR_STRING_SIZE];
+ return strerror_r(error, buf, ERROR_STRING_SIZE);
+}
+}
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Yunjin Lee <yunjin-.lee@samsung.com>
+ *
+ * Licensed 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.
+ */
+/**
+ * @file SafeFunction.h
+ * @author Yunjin Lee <yunjin-.lee@samsung.com>
+ * @version 1.0
+ * @brief Util for safe function.
+ */
+
+#include <string>
+
+namespace AskUser {
+namespace Util {
+
+std::string safeStrError(int error);
+
+}
+}
cynara_configuration_destroy(cynara_config);
while (repeats-- && !dead) {
- sprintf(clientPlus, "%s_%d", client, repeats);
+ snprintf(clientPlus, sizeof(clientPlus), "%s_%d", client, repeats);
ret = cynara_check(cynar, client, session, user, privilege);
printf("get ret [%d]: %s\n", ret, cystrerr(ret));
result += ret == CYNARA_API_ACCESS_ALLOWED ? 1 : -1;