diff --git a/src/lib/network_c_bindings.cc b/src/lib/network_c_bindings.cc index 4e2fb5abf..21c5f8702 100644 --- a/src/lib/network_c_bindings.cc +++ b/src/lib/network_c_bindings.cc @@ -26,9 +26,9 @@ CAPI(void) wkhtmltox_network_request_get_url(const wkhtmltox_network_request* re QByteArray s(reinterpret_cast(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(req)->setUrl(QUrl(QString::fromUtf8(url)));