Commit 14a55891 authored by Ulrich Sibiller's avatar Ulrich Sibiller

Loop.cpp: improve/fix usage of s(n)printf

parent 3066195d
...@@ -3939,7 +3939,8 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, ...@@ -3939,7 +3939,8 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr,
// this name cannot be changed as it is defined this way by the // this name cannot be changed as it is defined this way by the
// local X server // local X server
int len = sprintf(unixSocketName + 1, "/tmp/.X11-unix/X%d", xPort); int len = snprintf(unixSocketName + 1, DEFAULT_STRING_LENGTH - 1,
"/tmp/.X11-unix/X%d", xPort);
unixSocketName[0] = '\0'; unixSocketName[0] = '\0';
sockaddr_un *xServerAddrABSTRACT = new sockaddr_un; sockaddr_un *xServerAddrABSTRACT = new sockaddr_un;
...@@ -3977,7 +3978,7 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, ...@@ -3977,7 +3978,7 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr,
char unixSocketDir[DEFAULT_STRING_LENGTH]; char unixSocketDir[DEFAULT_STRING_LENGTH];
snprintf(unixSocketDir, DEFAULT_STRING_LENGTH - 1, "/tmp/.X11-unix"); snprintf(unixSocketDir, DEFAULT_STRING_LENGTH, "/tmp/.X11-unix");
#ifdef __APPLE__ #ifdef __APPLE__
...@@ -3990,7 +3991,7 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, ...@@ -3990,7 +3991,7 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr,
*slash = '\0'; *slash = '\0';
} }
snprintf(unixSocketDir, DEFAULT_STRING_LENGTH - 1, "%s", display); snprintf(unixSocketDir, DEFAULT_STRING_LENGTH, "%s", display);
} }
#endif #endif
...@@ -4019,7 +4020,8 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, ...@@ -4019,7 +4020,8 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr,
HandleCleanup(); HandleCleanup();
} }
sprintf(unixSocketName, "%s/X%d", unixSocketDir, xPort); snprintf(unixSocketName, DEFAULT_STRING_LENGTH, "%s/X%d",
unixSocketDir, xPort);
#ifdef __APPLE__ #ifdef __APPLE__
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment