summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2020-02-10 21:45:00 +0100
committerMartin Schwenke <martins@samba.org>2020-02-19 09:38:39 +0000
commitb058c6d3ed1bcc28ac02265d345cbda9a1df66a4 (patch)
tree923a132081b003e3bbba234452162c6b3c16ab7b
parentc9c0e69d17f401aea1cbc208be982f3e23536607 (diff)
downloadsamba-b058c6d3ed1bcc28ac02265d345cbda9a1df66a4.tar.gz
torture4: Use strlcpy() with size check instead of snprintf()
It's just test code, but we should give good examples where possible Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
-rw-r--r--source4/torture/libsmbclient/libsmbclient.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/source4/torture/libsmbclient/libsmbclient.c b/source4/torture/libsmbclient/libsmbclient.c
index 586e1772425..d29de06a494 100644
--- a/source4/torture/libsmbclient/libsmbclient.c
+++ b/source4/torture/libsmbclient/libsmbclient.c
@@ -53,17 +53,27 @@ static void auth_callback(const char *srv,
cli_credentials_get_username(popt_get_cmdline_credentials());
const char *password =
cli_credentials_get_password(popt_get_cmdline_credentials());
+ ssize_t ret;
if (workgroup != NULL) {
- snprintf(wg, wglen, "%s", workgroup);
+ ret = strlcpy(wg, workgroup, wglen);
+ if (ret >= wglen) {
+ abort();
+ }
}
if (username != NULL) {
- snprintf(un, unlen, "%s", username);
+ ret = strlcpy(un, username, unlen);
+ if (ret >= unlen) {
+ abort();
+ }
}
if (password != NULL) {
- snprintf(pw, pwlen, "%s", password);
+ ret = strlcpy(pw, password, pwlen);
+ if (ret >= pwlen) {
+ abort();
+ }
}
};