From f04ac49c61a834f2e6ebfa7aa228c778451d0faa Mon Sep 17 00:00:00 2001
From: "Leigh B. Stoller" <stoller@flux.utah.edu>
Date: Fri, 29 Aug 2003 19:36:20 +0000
Subject: [PATCH] Test for imagename <= sizeof(os_info.osname) since that is
 shorter than imagename, and this ID is used in both tables. They should be
 the same length in the DB, and I have added a TODO item for it.

---
 www/newimageid_ez.php3 | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/www/newimageid_ez.php3 b/www/newimageid_ez.php3
index d0f064dd1c..76a3028537 100644
--- a/www/newimageid_ez.php3
+++ b/www/newimageid_ez.php3
@@ -7,6 +7,13 @@
 include("defs.php3");
 include("showstuff.php3");
 
+#
+# XXX
+# Currently, TBDB_OSID_OSNAMELEN is shorter then TBDB_IMAGEID_IMAGENAMELEN
+# and that causes problems since we use the same id for both tables. For
+# now, test for the shorted of the two.
+# 
+
 #
 # Standard Testbed Header
 #
@@ -72,7 +79,7 @@ function SPITFORM($formfields, $errors)
 {
     global $uid, $projlist, $isadmin, $types_result, $oslist, $opmodes,
       $featurelist;
-    global $TBDB_IMAGEID_IMAGENAMELEN, $TBDB_NODEIDLEN;
+    global $TBDB_OSID_OSNAMELEN, $TBDB_NODEIDLEN;
     global $TBDB_OSID_VERSLEN, $TBBASE;
 
     echo "<center><b>
@@ -236,8 +243,8 @@ function SPITFORM($formfields, $errors)
                          onChange='SetPrefix(idform);'
                          name=\"formfields[imagename]\"
                          value=\"" . $formfields[imagename] . "\"
-	                 size=$TBDB_IMAGEID_IMAGENAMELEN
-                         maxlength=$TBDB_IMAGEID_IMAGENAMELEN>
+	                 size=$TBDB_OSID_OSNAMELEN
+                         maxlength=$TBDB_OSID_OSNAMELEN>
               </td>
           </tr>\n";
 
@@ -649,10 +656,10 @@ else {
 	    "Must be alphanumeric (includes _, -, +, and .)<br>".
 	    "and must begin with an alphanumeric";
     }
-    elseif (strlen($formfields[imagename]) > $TBDB_IMAGEID_IMAGENAMELEN) {
+    elseif (strlen($formfields[imagename]) > $TBDB_OSID_OSNAMELEN) {
 	$errors["Descriptor Name"] =
 	    "Too long! ".
-	    "Must be less than or equal to $TBDB_IMAGEID_IMAGENAMELEN";
+	    "Must be less than or equal to $TBDB_OSID_OSNAMELEN";
     }
 }
 
-- 
GitLab