mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
dthelp/Initialize.c: coverity CID 89569; unbounded src buf
This commit is contained in:
parent
0843325a43
commit
cd70f1660d
1 changed files with 23 additions and 20 deletions
|
@ -38,11 +38,13 @@ $COPYRIGHT$:
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/param.h> /* MAXPATHLEN */
|
#include <sys/param.h> /* MAXPATHLEN */
|
||||||
#include <sys/stat.h> /* mkdir */
|
#include <sys/stat.h> /* mkdir */
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
|
||||||
#include <X11/Xlibint.h> /* _XGetHostname() */
|
#include <X11/Xlibint.h> /* _XGetHostname() */
|
||||||
|
@ -623,29 +625,30 @@ static char *GetHomeDir (
|
||||||
char *dest)
|
char *dest)
|
||||||
{ /*$CODE$*/
|
{ /*$CODE$*/
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
extern char *getenv();
|
|
||||||
extern uid_t getuid();
|
|
||||||
extern struct passwd *getpwuid(), *getpwnam();
|
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
register char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
if((ptr = getenv("HOME")) != NULL)
|
if((ptr = getenv("HOME")) != NULL)
|
||||||
{
|
{
|
||||||
(void) strcpy(dest, ptr);
|
snprintf(dest, MAXPATHLEN, "%s", ptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if((ptr = getenv("USER")) != NULL)
|
if((ptr = getenv("USER")) != NULL)
|
||||||
{
|
{
|
||||||
pw = getpwnam(ptr);
|
char user[MAXPATHLEN];
|
||||||
}
|
snprintf(user, MAXPATHLEN, "%s", ptr);
|
||||||
else
|
pw = getpwnam(user);
|
||||||
{
|
}
|
||||||
uid = getuid();
|
else
|
||||||
pw = getpwuid(uid);
|
{
|
||||||
}
|
uid = getuid();
|
||||||
if (pw) (void) strcpy(dest, pw->pw_dir);
|
pw = getpwuid(uid);
|
||||||
else *dest = '\0';
|
}
|
||||||
|
if (pw)
|
||||||
|
snprintf(dest, MAXPATHLEN, "%s", pw->pw_dir);
|
||||||
|
else
|
||||||
|
*dest = '\0';
|
||||||
}
|
}
|
||||||
return dest;
|
return dest;
|
||||||
} /*$END$*/
|
} /*$END$*/
|
||||||
|
|
Loading…
Reference in a new issue