+/* sanitisecommandname:
+ *
+ * Converts the given command name to uppercase and checks for bad chars.
+ *
+ * Returns 1 if bad chars were found
+ */
+static int sanitisecommandname(const char *cmdname, char *cmdbuf) {
+ int len,i;
+
+ strncpy(cmdbuf,cmdname,MAX_COMMAND_LEN);
+ cmdbuf[MAX_COMMAND_LEN-1]='\0';
+
+ len=strlen(cmdbuf);
+
+ /* Sanity check the string */
+ for (i=0;i<len;i++) {
+ cmdbuf[i]=toupper(cmdbuf[i]);
+ if (cmdbuf[i]<'A' || cmdbuf[i]>'Z') {
+ /* Someone tried to register an invalid command name */
+ return 1;
+ }
+ }
+
+ return 0;
+}
+