Skip to content

Commit b138933

Browse files
committed
fix string truncation warning
1 parent 7a4555f commit b138933

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/agent/agent.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ ProxyAgent::ProxyAgent( bool is_server, bool dummy )
109109
(void)rmdir( dir.c_str() );
110110
return;
111111
}
112-
strncpy( sunaddr.sun_path, path.c_str(), sizeof( sunaddr.sun_path ) );
112+
strncpy( sunaddr.sun_path, path.c_str(), sizeof( sunaddr.sun_path ) - 1 );
113113
if ( bind( sock, (struct sockaddr*)&sunaddr, sizeof( sunaddr ) ) < 0 ) {
114114
(void)close( sock );
115115
(void)rmdir( dir.c_str() );
@@ -399,7 +399,7 @@ AgentConnection::AgentConnection( std::string agent_path, uint64_t id, ProxyAgen
399399
(void)close( sock );
400400
return;
401401
}
402-
strncpy( sunaddr.sun_path, agent_path.c_str(), sizeof( sunaddr.sun_path ) );
402+
strncpy( sunaddr.sun_path, agent_path.c_str(), sizeof( sunaddr.sun_path ) - 1 );
403403
if ( connect( sock, (struct sockaddr*)&sunaddr, sizeof( sunaddr ) ) < 0 ) {
404404
(void)close( sock );
405405
return;

0 commit comments

Comments
 (0)