Message ID | 20230120222607.gjyi4uxyg4in52sp@kora (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | atari: stricter partition validation | expand |
diff --git a/block/partitions/atari.c b/block/partitions/atari.c index 9655c728262a..5f4d5faab399 100644 --- a/block/partitions/atari.c +++ b/block/partitions/atari.c @@ -20,7 +20,7 @@ least one of the primary entries is ok this way */ #define VALID_PARTITION(pi,hdsiz) \ (((pi)->flg & 1) && \ - isalnum((pi)->id[0]) && isalnum((pi)->id[1]) && isalnum((pi)->id[2]) && \ + (OK_id((pi)->id) || memcmp((pi)->id, "XGM", 3)) && \ be32_to_cpu((pi)->st) <= (hdsiz) && \ be32_to_cpu((pi)->st) + be32_to_cpu((pi)->siz) <= (hdsiz))
The atari partition detect sequence has a simple sequence, if the three consecutive characters at the offset are alphanumeric, then call it as an atari partition. This results in many false positive where devices are shown as ATARI partitions when they are not. There are many users suffering this and they are finding ways to circumvent it (Search for "linux atari partition" in your popular search engine). This is more common with cloud based installations where a device with garbage is used and is falsely detected as an ATARI partition. Make the detect condition stricter so Linux does not detect them as ATARI and continues with the detection sequence. There is already an existing function OK_id() which checks for legitimate partition strings. Use the function in the VALID_PARTITION() sequence. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>