aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2017-11-24 00:54:14 +0100
committerUlrich Sibiller <uli42@gmx.de>2018-01-07 01:27:07 +0100
commit2836c72f786e550252d75cf5f274245e8de5b5f9 (patch)
tree652bab2267f80f9a12534ad0db9e4274ae4232d1
parent08912ef304f019cd473243d389a9dee237b01bea (diff)
downloadnx-libs-2836c72f786e550252d75cf5f274245e8de5b5f9.tar.gz
nx-libs-2836c72f786e550252d75cf5f274245e8de5b5f9.tar.bz2
nx-libs-2836c72f786e550252d75cf5f274245e8de5b5f9.zip
Keyboard.c: replace malloc + strcpy by asprintf
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Keyboard.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
index 9f1764cd0..cddb3457e 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
@@ -1899,18 +1899,16 @@ void nxagentKeycodeConversionSetup(void)
char *sessionpath = nxagentGetSessionPath();
if (sessionpath)
{
- int keyboard_file_path_size = strlen(sessionpath) + strlen("/keyboard");
- char *keyboard_file_path = malloc((keyboard_file_path_size + 1) * sizeof(char));
+ char *keyboard_file_path = NULL;
FILE *keyboard_file;
- if (!keyboard_file_path)
+ if ((asprintf(&keyboard_file_path, "%s/keyboard", sessionpath) == -1))
{
free(sessionpath);
FatalError("malloc for keyboard file path failed.");
}
- strcpy(keyboard_file_path, sessionpath);
- strcat(keyboard_file_path, "/keyboard");
free(sessionpath);
- if ((keyboard_file = fopen(keyboard_file_path, "w"))) {
+ if ((keyboard_file = fopen(keyboard_file_path, "w")))
+ {
if (drules)
fprintf(keyboard_file, "rules=\"%s\"\n", drules[0] == '\0' ? "," : drules);
if (dmodel)