_tdm_display_load_module(tdm_private_display *private_display)
{
const char *module_name;
- char module[TDM_NAME_LEN];
struct dirent **namelist;
- int n;
+ int n, len;
tdm_error ret = 0;
module_name = getenv("TDM_MODULE");
if (!module_name)
module_name = TDM_DEFAULT_MODULE;
- strncpy(module, module_name, TDM_NAME_LEN - 1);
- module[TDM_NAME_LEN - 1] = '\0';
+ len = strlen(module_name);
+ if (len > TDM_NAME_LEN - 1) {
+ TDM_ERR("TDM_MODULE is too long\n");
+ return TDM_ERROR_OPERATION_FAILED;
+ }
/* load bufmgr priv from default lib */
- ret = _tdm_display_load_module_with_file(private_display, (const char*)module);
+ ret = _tdm_display_load_module_with_file(private_display, module_name);
if (ret == TDM_ERROR_NONE)
return TDM_ERROR_NONE;
{
const char *dir = NULL;
char socket_path[TDM_NAME_LEN * 2];
- int ret = -1;
+ int ret = -1, len;
uid_t uid;
gid_t gid;
/* LCOV_EXCL_STOP */
}
+ len = strlen(dir);
+ if (len > TDM_NAME_LEN - 1) {
+ TDM_ERR("XDG_RUNTIME_DIR is too long\n");
+ return;
+ }
+
strncpy(socket_path, dir, TDM_NAME_LEN - 1);
socket_path[TDM_NAME_LEN - 1] = '\0';