[2001] in Moira

home help back first fref pref prev next nref lref last post

Deal gracefully with empty string object names.

daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Fri Feb 14 18:53:42 2003

Message-Id: <200302142353.SAA06310@brad-majors.mit.edu>
To: moiradev@MIT.EDU
Date: Fri, 14 Feb 2003 18:53:34 -0500
From: Garry Zacheiss <zacheiss@MIT.EDU>

	Below is a patch originally from Karl and adapted and expanded
by me to make moirad fail gracefully when someone attempts to create or
rename an object with the empty string as a name.  I'm not wild about
the error code being returned, but the alternatives are to use
MR_BAD_CHAR or to add a new one; let me know if you have strong
opinions.

Index: qvalidate.pc
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/server/qvalidate.pc,v
retrieving revision 2.21
diff -u -r2.21 qvalidate.pc
--- qvalidate.pc	1 Apr 2001 05:31:25 -0000	2.21
+++ qvalidate.pc	14 Feb 2003 23:46:30 -0000
@@ -160,6 +160,8 @@
       if (illegalchars[(int)*s++])
 	return MR_BAD_CHAR;
     }
+  if (!*s)
+    return MR_RESERVED;
 
   /* check for length */
   tname = table_name[vo->table];
@@ -233,6 +235,8 @@
 	    *c = toupper(*c);
 	}
     }
+  if (!*name)
+    return MR_RESERVED;
   sprintf(stmt_buf, "SELECT DISTINCT COUNT(*) FROM %s WHERE %s.%s = '%s'",
 	  table_name[vo->table], table_name[vo->table], namefield, name);
   dosql(sqlbuffer);
@@ -264,6 +268,8 @@
 	    *c = toupper(*c);
 	}
     }
+  if (!*name)
+    return MR_RESERVED;
   namefield = vo->namefield;
   idfield = vo->idfield;
   id = -1;

home help back first fref pref prev next nref lref last post