Skip to content

Commit

Permalink
strcpy_s does not truncate, use strncpy_s instead, and ensure the nul…
Browse files Browse the repository at this point in the history
…l-terminator is always included.
  • Loading branch information
poizan42 committed Jun 12, 2017
1 parent c1d0ae9 commit 39d2b29
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/network_c_bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ CAPI(void) wkhtmltox_network_request_get_url(const wkhtmltox_network_request* re
QByteArray s(reinterpret_cast<const QNetworkRequest*>(req)->url().toEncoded());
int bufLen(*cb);

*cb = s.length();
*cb = s.length() + 1; // Include the null-terminator
if (url)
strcpy_s(url, bufLen, s.constData());
strncpy_s(url, bufLen, s.constData(), bufLen - 1 /* ensure the null-terminator is included. */);
}
CAPI(void) wkhtmltox_network_request_set_url(wkhtmltox_network_request* req, const char* url) {
reinterpret_cast<QNetworkRequest*>(req)->setUrl(QUrl(QString::fromUtf8(url)));
Expand Down

0 comments on commit 39d2b29

Please sign in to comment.