Skip to content

Commit

Permalink
src: replace sprintf() with snprintf()
Browse files Browse the repository at this point in the history
  • Loading branch information
vszakats committed Mar 12, 2018
1 parent e54ef17 commit c274a3f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ agent_transact_pageant(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx)
return _libssh2_error(agent->session, LIBSSH2_ERROR_AGENT_PROTOCOL,
"found no pageant");

sprintf(mapname, "PageantRequest%08x", (unsigned)GetCurrentThreadId());
snprintf(mapname, sizeof(mapname),
"PageantRequest%08x%c", (unsigned)GetCurrentThreadId(), '\0');
filemap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
0, PAGEANT_MAX_MSGLEN, mapname);

Expand Down
2 changes: 1 addition & 1 deletion src/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ channel_x11_req(LIBSSH2_CHANNEL *channel, int single_connection,

_libssh2_random(buffer, LIBSSH2_X11_RANDOM_COOKIE_LEN / 2);
for(i = 0; i < (LIBSSH2_X11_RANDOM_COOKIE_LEN / 2); i++) {
sprintf((char *)&s[i*2], "%02X", buffer[i]);
snprintf((char *)&s[i*2], 3, "%02X%c", buffer[i], '\0');
}
}
s += cookie_len;
Expand Down

0 comments on commit c274a3f

Please sign in to comment.