View | Details | Raw Unified | Return to bug 147492
Collapse All | Expand All

(-)scim-bridge/files/patch-agent_scim-bridge-agent-accept-listener.cpp (+29 lines)
Line 0 Link Here
1
2
$FreeBSD$
3
4
--- agent/scim-bridge-agent-accept-listener.cpp.orig
5
+++ agent/scim-bridge-agent-accept-listener.cpp
6
@@ -106,12 +106,12 @@
7
     struct sockaddr_un socket_addr;
8
     memset (&socket_addr, 0, sizeof (struct sockaddr_un));
9
     socket_addr.sun_family = AF_UNIX;
10
-    strcpy (socket_addr.sun_path, socket_path);
11
+    strncpy (socket_addr.sun_path, socket_path, 104); /* 104 is the maximum length of sun_path in FreeBSD */
12
     
13
     const int MAX_TRIAL = 5;
14
     for (int i = 0; i < MAX_TRIAL; ++i) {
15
         scim_bridge_pdebugln (8, "Pinging for the another agent process...");
16
-        if (connect (socket_fd, (struct sockaddr*)&socket_addr, sizeof (socket_addr.sun_family) + strlen (socket_addr.sun_path))) {
17
+        if (connect (socket_fd, (struct sockaddr*)&socket_addr, SUN_LEN(&socket_addr))) {
18
             if (i == MAX_TRIAL - 1) {
19
                 scim_bridge_pdebugln (6, "It seems like there is no other agent for the old socket.");
20
                 break;
21
@@ -163,7 +163,7 @@
22
         return RETVAL_FAILED;
23
     }
24
     
25
-    if (bind (socket_fd, (struct sockaddr*)&socket_addr, strlen (socket_addr.sun_path) + sizeof (socket_addr.sun_family)) != 0) {
26
+    if (bind (socket_fd, (struct sockaddr*)&socket_addr, SUN_LEN(&socket_addr)) != 0) {
27
         scim_bridge_perrorln ("Cannot bind the socket: %s", strerror (errno));
28
         close (socket_fd);
29
         socket_fd = -1;

Return to bug 147492