secure strscpy by replacing with strncpy

This commit is contained in:
Michael Stapelberg
2011-07-23 22:22:36 +02:00
parent a402480ad0
commit fdd098b010
3 changed files with 3 additions and 3 deletions

View File

@ -231,7 +231,7 @@ int main(int argc, char *argv[]) {
struct sockaddr_un addr;
memset(&addr, 0, sizeof(struct sockaddr_un));
addr.sun_family = AF_LOCAL;
strcpy(addr.sun_path, socket_path);
strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1);
if (connect(sockfd, (const struct sockaddr*)&addr, sizeof(struct sockaddr_un)) < 0)
err(EXIT_FAILURE, "Could not connect to i3");