Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
525e1516
Commit
525e1516
authored
Jan 03, 2018
by
Ulrich Sibiller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Error.c: replace strcpy/strcat by snprintf
parent
7d87e5a0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
20 deletions
+12
-20
Display.c
nx-X11/programs/Xserver/hw/nxagent/Display.c
+1
-2
Error.c
nx-X11/programs/Xserver/hw/nxagent/Error.c
+11
-18
No files found.
nx-X11/programs/Xserver/hw/nxagent/Display.c
View file @
525e1516
...
...
@@ -1873,8 +1873,7 @@ static FILE *nxagentLookForIconFile(char *iconName, const char *permission,
/* append slash and icon name */
if
(
strlen
(
singlePath
)
+
strlen
(
iconName
)
+
1
<
sizeof
(
singlePath
))
{
strncat
(
singlePath
,
slash
,
1
);
strcat
(
singlePath
,
iconName
);
snprintf
(
singlePath
+
strlen
(
singlePath
),
sizeof
(
singlePath
),
"%s%s"
,
slash
,
iconName
);
if
((
fptr
=
fopen
(
singlePath
,
permission
))
!=
NULL
)
{
...
...
nx-X11/programs/Xserver/hw/nxagent/Error.c
View file @
525e1516
...
...
@@ -359,14 +359,14 @@ char *nxagentGetHomePath(void)
#endif
}
s
trncpy
(
nxagentHomeDir
,
homeEnv
,
DEFAULT_STRING_LENGTH
-
1
);
s
nprintf
(
nxagentHomeDir
,
DEFAULT_STRING_LENGTH
,
"%s"
,
homeEnv
);
#ifdef TEST
fprintf
(
stderr
,
"nxagentGetHomePath: Assuming NX user's home directory '%s'.
\n
"
,
nxagentHomeDir
);
#endif
}
homePath
=
(
char
*
)
malloc
(
strlen
(
nxagentHomeDir
)
+
1
);
homePath
=
strdup
(
nxagentHomeDir
);
if
(
homePath
==
NULL
)
{
...
...
@@ -377,8 +377,6 @@ char *nxagentGetHomePath(void)
return
NULL
;
}
strcpy
(
homePath
,
nxagentHomeDir
);
return
homePath
;
}
...
...
@@ -434,8 +432,7 @@ char *nxagentGetRootPath(void)
fprintf
(
stderr
,
"nxagentGetRootPath: Assuming NX root directory in '%s'.
\n
"
,
homeEnv
);
#endif
strcpy
(
nxagentRootDir
,
homeEnv
);
strcat
(
nxagentRootDir
,
"/.nx"
);
snprintf
(
nxagentRootDir
,
DEFAULT_STRING_LENGTH
,
"%s/.nx"
,
homeEnv
);
free
(
homeEnv
);
...
...
@@ -468,7 +465,7 @@ char *nxagentGetRootPath(void)
return
NULL
;
}
s
trcpy
(
nxagentRootDir
,
rootEnv
);
s
nprintf
(
nxagentRootDir
,
DEFAULT_STRING_LENGTH
,
"%s"
,
rootEnv
);
}
#ifdef TEST
...
...
@@ -478,7 +475,7 @@ char *nxagentGetRootPath(void)
}
rootPath
=
malloc
(
strlen
(
nxagentRootDir
)
+
1
);
rootPath
=
strdup
(
nxagentRootDir
);
if
(
rootPath
==
NULL
)
{
...
...
@@ -489,8 +486,6 @@ char *nxagentGetRootPath(void)
return
NULL
;
}
strcpy
(
rootPath
,
nxagentRootDir
);
return
rootPath
;
}
...
...
@@ -527,9 +522,7 @@ char *nxagentGetSessionPath(void)
return
NULL
;
}
strcpy
(
nxagentSessionDir
,
rootPath
);
free
(
rootPath
);
snprintf
(
nxagentSessionDir
,
DEFAULT_STRING_LENGTH
,
"%s"
,
rootPath
);
if
(
strlen
(
nxagentSessionDir
)
+
strlen
(
"/C-"
)
+
strlen
(
nxagentSessionId
)
>
DEFAULT_STRING_LENGTH
-
1
)
{
...
...
@@ -538,12 +531,14 @@ char *nxagentGetSessionPath(void)
nxagentSessionDir
);
#endif
free
(
rootPath
);
return
NULL
;
}
s
trcat
(
nxagentSessionDir
,
"/C-"
);
s
nprintf
(
nxagentSessionDir
,
DEFAULT_STRING_LENGTH
,
"%s/C-%s"
,
rootPath
,
nxagentSessionId
);
strcat
(
nxagentSessionDir
,
nxagentSessionId
);
free
(
rootPath
);
if
((
stat
(
nxagentSessionDir
,
&
dirStat
)
==
-
1
)
&&
(
errno
==
ENOENT
))
{
...
...
@@ -605,9 +600,7 @@ void nxagentGetClientsPath()
return
;
}
strcpy
(
nxagentClientsLogName
,
sessionPath
);
strcat
(
nxagentClientsLogName
,
"/clients"
);
snprintf
(
nxagentClientsLogName
,
DEFAULT_STRING_LENGTH
,
"%s/clients"
,
sessionPath
);
free
(
sessionPath
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment