diff --git a/src/agent.c b/src/agent.c index 785e3c9..b797cbd 100644 --- a/src/agent.c +++ b/src/agent.c @@ -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, @@ -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,