]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Case insensitive when checking checksum value.
authorlongpanda <admin@ventoy.net>
Mon, 25 Oct 2021 01:29:51 +0000 (09:29 +0800)
committerlongpanda <admin@ventoy.net>
Mon, 25 Oct 2021 01:29:51 +0000 (09:29 +0800)
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
INSTALL/grub/checksum.cfg

index 248a76820c8447c39093d0a60526bc05762e7211..9f78271f667834667ea1f8575d83d78109937d10 100644 (file)
@@ -918,6 +918,38 @@ static grub_err_t ventoy_cmd_strbegin(grub_extcmd_context_t ctxt, int argc, char
     return 0;
 }
 
+static grub_err_t ventoy_cmd_strcasebegin(grub_extcmd_context_t ctxt, int argc, char **args)
+{
+    char *c0, *c1;
+    
+    (void)ctxt;
+
+    if (argc != 2)
+    {
+        return 1;
+    }
+
+    c0 = args[0];
+    c1 = args[1];
+
+    while (*c0 && *c1)
+    {
+        if ((*c0 != *c1) && (*c0 != grub_toupper(*c1)))
+        {
+            return 1;
+        }
+        c0++;
+        c1++;
+    }
+
+    if (*c1)
+    {
+        return 1;
+    }
+
+    return 0;
+}
+
 static grub_err_t ventoy_cmd_incr(grub_extcmd_context_t ctxt, int argc, char **args)
 {
     long value_long = 0;
@@ -5051,6 +5083,7 @@ static cmd_para ventoy_cmds[] =
     { "vt_mod",  ventoy_cmd_mod,  0, NULL, "{Int} {Int} {Var}",   "mod integer variable",    NULL },
     { "vt_strstr",  ventoy_cmd_strstr,  0, NULL, "",   "",    NULL },
     { "vt_str_begin",  ventoy_cmd_strbegin,  0, NULL, "",   "",    NULL },
+    { "vt_str_casebegin",  ventoy_cmd_strcasebegin,  0, NULL, "",   "",    NULL },
     { "vt_debug", ventoy_cmd_debug, 0, NULL, "{on|off}",   "turn debug on/off",    NULL },
     { "vtdebug", ventoy_cmd_debug, 0, NULL, "{on|off}",   "turn debug on/off",    NULL },
     { "vtbreak", ventoy_cmd_break, 0, NULL, "{level}",   "set debug break",    NULL },
index cea88fce58566ee38a077b70bea58809342ea579..21dd0de0290ac17974c92af6aaaff862a8320617 100644 (file)
@@ -5,8 +5,8 @@ if [ -e "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.md5" ]; then
         md5sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
         
         vt_1st_line "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.md5" vtReadChecksum
-        
-        if vt_str_begin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
+                
+        if vt_str_casebegin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
             echo -e "\n\nCheck MD5 value with .md5 file.  [ OK ]"
         else
             echo -e "\n\nCheck MD5 value with .md5 file.  [ FAIL ]"
@@ -33,7 +33,7 @@ if [ -e "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha1" ]; then
         
         vt_1st_line "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha1" vtReadChecksum
         
-        if vt_str_begin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
+        if vt_str_casebegin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
             echo -e "\n\nCheck SHA1 value with .sha1 file.  [ OK ]"
         else
             echo -e "\n\nCheck SHA1 value with .sha1 file.  [ FAIL ]"
@@ -62,7 +62,7 @@ if [ -e "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha256" ]; then
         
         vt_1st_line "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha256" vtReadChecksum
         
-        if vt_str_begin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
+        if vt_str_casebegin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
             echo -e "\n\nCheck SHA256 value with .sha256 file.  [ OK ]"
         else
             echo -e "\n\nCheck SHA256 value with .sha256 file.  [ FAIL ]"
@@ -91,7 +91,7 @@ if [ -e "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha512" ]; then
         
         vt_1st_line "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}.sha512" vtReadChecksum
         
-        if vt_str_begin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
+        if vt_str_casebegin "$vtReadChecksum" "$VT_LAST_CHECK_SUM"; then
             echo -e "\n\nCheck SHA512 value with .sha512 file.  [ OK ]"
         else
             echo -e "\n\nCheck SHA512 value with .sha512 file.  [ FAIL ]"