From: Peter Howkins Date: Sat, 28 Apr 2018 22:47:05 +0000 (+0100) Subject: dtlogin: Resolve some coverity issues, including those thought previously fixed X-Git-Tag: 2.2.4a~50 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e14e74231cdce11c887c77ecd6cf3a4d0b956577;p=oweals%2Fcde.git dtlogin: Resolve some coverity issues, including those thought previously fixed --- diff --git a/cde/programs/dtlogin/account.c b/cde/programs/dtlogin/account.c index fbea9b20..27f51ca0 100644 --- a/cde/programs/dtlogin/account.c +++ b/cde/programs/dtlogin/account.c @@ -215,7 +215,7 @@ Account( struct display *d, char *user, char *line, pid_t pid, * Currently, an unlimited number of foreign displays can log in. */ - if (user) strncpy(u->ut_user, user, sizeof(u->ut_user)); + if (user) snprintf(u->ut_user, sizeof(u->ut_user), "%s", user); if (line) { #ifdef _AIX /* diff --git a/cde/programs/dtlogin/resource.c b/cde/programs/dtlogin/resource.c index 4314a6b4..70e2619c 100644 --- a/cde/programs/dtlogin/resource.c +++ b/cde/programs/dtlogin/resource.c @@ -409,6 +409,7 @@ GetResource( char *name, char *class, int valueType, char **valuep, char *type; XrmValue value; char *string, *new_string; + char empty[] = ""; char str_buf[50]; int len; @@ -422,8 +423,13 @@ GetResource( char *name, char *class, int valueType, char **valuep, } else { - string = default_value; - len = (string == NULL ? 0 : strlen (string)); + if(default_value) { + string = default_value; + len = strlen (string); + } else { + string = empty; + len = 0; + } } Debug ("%s/%s value %*.*s\n", name, class, len, len, string); diff --git a/cde/programs/dtlogin/session.c b/cde/programs/dtlogin/session.c index f5f45266..34332058 100644 --- a/cde/programs/dtlogin/session.c +++ b/cde/programs/dtlogin/session.c @@ -754,11 +754,8 @@ LoadAltDtsResources(struct display *d) Debug("LoadAltDtsResources- cant access %s.\n", resources); Debug("\t %s. Falling back to C.\n", strerror(errno)); - if (resources) - { - free (resources); - resources = NULL; - } + free (resources); + resources = NULL; resources = _ExpandLang(dirname[j], "C"); if (access (resources, R_OK) != 0) @@ -2073,7 +2070,7 @@ RunGreeter( struct display *d, struct greet_info *greet, language = d->language; #endif /* ENABLE_DYNAMIC_LANGLIST */ - if ( d->language && strlen(d->language) > 0 ) + if (env && d->language && strlen(d->language) > 0 ) env = setLang(d, env, language); } diff --git a/cde/programs/dtlogin/verify.c b/cde/programs/dtlogin/verify.c index af9f8fd1..414a505f 100644 --- a/cde/programs/dtlogin/verify.c +++ b/cde/programs/dtlogin/verify.c @@ -383,7 +383,7 @@ userEnv( langlist = languageList; #endif /* ENABLE_DYNAMIC_LANGLIST */ - if (d->language && strlen(d->language) > 0) + if (env && d->language && strlen(d->language) > 0) env = setLang(d, env, langlist); #if 0 /* setting LC_ALL can cause undesirable side effects -- bf@hp */ diff --git a/cde/programs/dtlogin/vgmain.c b/cde/programs/dtlogin/vgmain.c index af673915..b51816ed 100644 --- a/cde/programs/dtlogin/vgmain.c +++ b/cde/programs/dtlogin/vgmain.c @@ -1557,7 +1557,8 @@ MakeGreeting( void ) */ - if ( strlen(greetInfo.labelString) == 0 || + if ( !greetInfo.labelString || + strlen(greetInfo.labelString) == 0 || strcmp(greetInfo.labelString, "None") == 0 || strcmp(greetInfo.labelString, "none") == 0 )