Don't strncpy a string to itself
authorKen Raeburn <raeburn@mit.edu>
Sat, 14 Oct 2006 01:00:40 +0000 (01:00 +0000)
committerKen Raeburn <raeburn@mit.edu>
Sat, 14 Oct 2006 01:00:40 +0000 (01:00 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18701 dc483132-0cff-0310-8789-dd5450dbe970

src/appl/gssftp/ftp/ftp.c

index 6ef4e886eba2c909b00f829b8bc44d0af6437306..93ace908871fcadddcf274bd7cb8d57e55446f73 100644 (file)
@@ -1684,7 +1684,8 @@ void pswitch(int flag)
        ip->connect = connected;
        connected = op->connect;
        if (hostname) {
-               (void) strncpy(ip->name, hostname, sizeof(ip->name) - 1);
+               if (ip->name != hostname)
+                       (void) strncpy(ip->name, hostname, sizeof(ip->name) - 1);
                ip->name[strlen(ip->name)] = '\0';
        } else
                ip->name[0] = 0;