From: Kay Sievers Date: Thu, 12 Jun 2008 05:20:14 +0000 (+0200) Subject: cdrom_id: fix recognition of blank media X-Git-Tag: 174~1682 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9bbdf6eb3c0d84bf906176a51e4cda10882dadc6;p=systemd cdrom_id: fix recognition of blank media Thanks to David! --- diff --git a/extras/cdrom_id/cdrom_id.c b/extras/cdrom_id/cdrom_id.c index 6d3326bd..a1135665 100644 --- a/extras/cdrom_id/cdrom_id.c +++ b/extras/cdrom_id/cdrom_id.c @@ -470,9 +470,13 @@ static int cd_media_toc(int fd) info("READ TOC: len: %d\n", len); if (len > sizeof(toc)) return -1; - if (len < 8) + if (len < 2) return -1; + /* empty media has no tracks */ + if (len < 8) + return 0; + scsi_cmd_set(&sc, 0, 0x43); scsi_cmd_set(&sc, 6, header[2]); /* First Track/Session Number */ scsi_cmd_set(&sc, 7, len >> 8);