projects
/
platform
/
upstream
/
libatasmart.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
aa53a8f
)
do a basic all-NUL check for the identify data before accepting it is valid
author
Lennart Poettering
<lennart@poettering.net>
Sun, 12 Apr 2009 21:28:13 +0000
(23:28 +0200)
committer
Lennart Poettering
<lennart@poettering.net>
Sun, 12 Apr 2009 21:28:13 +0000
(23:28 +0200)
atasmart.c
patch
|
blob
|
history
diff --git
a/atasmart.c
b/atasmart.c
index
435de05
..
ffc5fab
100644
(file)
--- a/
atasmart.c
+++ b/
atasmart.c
@@
-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;