From e6ce37679f121672802ea69e21d16ea360364389 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 8 Feb 2007 14:55:21 +0000 Subject: r21239: if the workgroup name is longer than 16 chars we get garbage in the string server_len is usually 256 (fstring). Correctly terminate saving the lenght (This used to be commit e7e44554bf7c61020e2c5c652e3f8f37a296d3aa) --- source3/libsmb/libsmbclient.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source3/libsmb/libsmbclient.c') diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c index 48f6c3a9c2..b3c873145f 100644 --- a/source3/libsmb/libsmbclient.c +++ b/source3/libsmb/libsmbclient.c @@ -339,14 +339,15 @@ smbc_parse_path(SMBCCTX *context, goto decoding; if (*p == '/') { + int wl = strlen(context->workgroup); - strncpy(server, context->workgroup, - ((strlen(context->workgroup) < 16) - ? strlen(context->workgroup) - : 16)); - server[server_len - 1] = '\0'; + if (wl > 16) { + wl = 16; + } + + strncpy(server, context->workgroup, wl); + server[wl] = '\0'; return 0; - } /* -- cgit