diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-04-12 23:28:13 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-04-12 23:28:13 +0200 |
commit | 86893f57fd869e6a22bfb3805268e9a639c5fdcd (patch) | |
tree | 485dd2d77b6125704ab9ade9fb476c6ed056f795 /atasmart.c | |
parent | aa53a8f336391712b38a3f21a76ccf2596f99db9 (diff) |
do a basic all-NUL check for the identify data before accepting it is valid
Diffstat (limited to 'atasmart.c')
-rw-r--r-- | atasmart.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -527,10 +527,12 @@ static int disk_identify_device(SkDisk *d) { uint16_t cmd[6]; int ret; size_t len = 512; + const uint8_t *p; if (d->type == SK_DISK_TYPE_BLOB) return 0; + memset(d->identify, 0, len); memset(cmd, 0, sizeof(cmd)); cmd[1] = htons(1); @@ -543,6 +545,18 @@ static int disk_identify_device(SkDisk *d) { return -1; } + /* Check if IDENTIFY data is all NULs */ + for (p = d->identify; p < (const uint8_t*) d->identify+len; p++) + if (*p) { + p = NULL; + break; + } + + if (p) { + errno = EIO; + return -1; + } + d->identify_valid = TRUE; return 0; |