Subject: bug#31111: Partition table wrongly identified as "atari"

From: bouke_1 <[email-masked]>
Date: Tue, 10 Apr 2018 13:59:05 +0200

I quickly looked through the atari_probe routine in the Atari patch 
code, and I may have found the logic error. At the bottom:

      } /* no XGM so try ICD */
+         else if (atr_part_valid (&table.icd_part[0], rs_hd_size)
+                  && atr_part_known (&table.icd_part[0], 
atr_known_icd_pid)) {
+               for (i = 1; i < N_ICD; i++) {
+                       if (atr_part_trash (&table.icd_part[i], 
rs_hd_size))
+                               return 0;
+               }
+       }
+
+       return 1;
+ }

Correct me if I'm wrong (I know little about partitioning and less about 
atari disks), but it looks if the partition (or whatever) does not check 
out as "XGM" and either atr_part_valid  or atr_part_known  returns 
false, the routine will return 1 (meaning: this checks out as an atari 
disk).

In order to reach this part, only a few things need to check out (in the 
top part of the routine): three id values need to be alphanumeric and a 
couple of sizes need to be realistic (i.e., in my case, between 0 and 
500G). That does not seem like something that can never happen by 
coincidence for a non-atari disk.

I would guess it may be a good idea to add another "else return 0;" line 
so that if the disk is neither "XGM" nor "ICD" (whatever that may mean), 
it is not detected as atari disk.

I have the neither the stomach nor the means or the time to look into 
this but if I can assist in any way please let me know.

Bouke