Skip to content

Commit

Permalink
agent_connect_unix: make sure there's a trailing zero
Browse files Browse the repository at this point in the history
... if the path name was too long. Reported by Coverity CID 89801.
  • Loading branch information
bagder committed Dec 23, 2014
1 parent 8a731d6 commit 637c909
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/agent.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2009 by Daiki Ueno
* Copyright (C) 2014 by Daniel Stenberg
* Copyright (C) 2010-2014 by Daniel Stenberg
* All rights reserved.
*
* Redistribution and use in source and binary forms,
Expand Down Expand Up @@ -159,6 +159,8 @@ agent_connect_unix(LIBSSH2_AGENT *agent)

s_un.sun_family = AF_UNIX;
strncpy (s_un.sun_path, path, sizeof s_un.sun_path);
s_un.sun_path[sizeof(s_un.sun_path)-1]=0; /* make sure there's a trailing
zero */
if (connect(agent->fd, (struct sockaddr*)(&s_un), sizeof s_un) != 0) {
close (agent->fd);
return _libssh2_error(agent->session, LIBSSH2_ERROR_AGENT_PROTOCOL,
Expand Down

0 comments on commit 637c909

Please sign in to comment.