Workgroup name truncation (create, find)

Paul Szabo psz at maths.usyd.edu.au
Mon Sep 13 21:40:51 GMT 2004


I think I found a bug in Samba 3.0.5, patch below.

Cheers,

Paul Szabo - psz at maths.usyd.edu.au  http://www.maths.usyd.edu.au:8000/u/psz/
School of Mathematics and Statistics  University of Sydney   2006  Australia


--- nmbd/nmbd_workgroupdb.c.orig	Wed Jul 21 02:28:10 2004
+++ nmbd/nmbd_workgroupdb.c	Tue Sep 14 07:31:16 2004
@@ -158,11 +158,28 @@
 {
 	struct work_record *ret;
   
+/* PSz 14 Sep 04 */
+/* Use same truncation as create_workgroup (or never find it). Silently. */
+
+	nstring nname;
+	unstring tname;
+	char *namep;
+	errno = 0;
+	push_ascii_nstring(nname, name);
+	if (errno == E2BIG) {
+		pull_ascii_nstring(tname, sizeof(tname), nname);
+		namep = tname;
+		DEBUG(4,("find_workgroup_on_subnet: workgroup name %s is too long. Truncating to %s\n",
+			name, namep));
+	} else {
+		namep = (char*)name;
+	}
+
 	DEBUG(4, ("find_workgroup_on_subnet: workgroup search for %s on subnet %s: ",
-		name, subrec->subnet_name));
+		namep, subrec->subnet_name));
   
 	for (ret = subrec->workgrouplist; ret; ret = ret->next) {
-		if (strequal(ret->work_group,name)) {
+		if (strequal(ret->work_group,namep)) {
 			DEBUGADD(4, ("found.\n"));
 			return(ret);
 		}


More information about the samba-technical mailing list