ctdb: Fix CID 1327222 Copy into fixed size buffer
authorVolker Lendecke <vl@samba.org>
Tue, 17 May 2016 09:39:38 +0000 (11:39 +0200)
committerUri Simchoni <uri@samba.org>
Tue, 17 May 2016 19:21:30 +0000 (21:21 +0200)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
Autobuild-User(master): Uri Simchoni <uri@samba.org>
Autobuild-Date(master): Tue May 17 21:21:30 CEST 2016 on sn-devel-144

ctdb/tests/src/fake_ctdbd.c

index 9a53f466a5dd5bb4c862f841b8eff79f19399660..462ecb7753d88a6490972247aef73abc462806bc 100644 (file)
@@ -2097,11 +2097,17 @@ static bool server_recv(struct tevent_req *req, int *perr)
 static int socket_init(const char *sockpath)
 {
        struct sockaddr_un addr;
+       size_t len;
        int ret, fd;
 
        memset(&addr, 0, sizeof(addr));
        addr.sun_family = AF_UNIX;
-       strcpy(addr.sun_path, sockpath);
+
+       len = strlcpy(addr.sun_path, sockpath, sizeof(addr.sun_path));
+       if (len >= sizeof(addr.sun_path)) {
+               fprintf(stderr, "path too long: %s\n", sockpath);
+               return -1;
+       }
 
        fd = socket(AF_UNIX, SOCK_STREAM, 0);
        if (fd == -1) {