1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-29 15:22:30 +03:00

Fix message check

Check pointer from strchr for NULL instead of crash later.
Badly formated message would have crash dmeventd otherwise.
This commit is contained in:
Zdenek Kabelac 2012-02-10 15:17:52 +00:00
parent 4d95ccc696
commit 8380b37529
2 changed files with 4 additions and 3 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.70 -
===================================
Fix dm_event_get_version() check.
Add pointer test for dependency check in _add_dev().
Validate name and uuid params of dm_tree_add_new_dev_with_udev_flags().
Do not crash for dm_report_init() sort_key == NULL and behave like "".

View File

@ -811,11 +811,11 @@ int dm_event_get_version(struct dm_event_fifos *fifos, int *version) {
p = msg.data;
*version = 0;
p = strchr(p, ' ') + 1; /* Message ID */
p = strchr(p, ' '); /* Message ID */
if (!p) return 0;
p = strchr(p, ' ') + 1; /* HELLO */
p = strchr(p + 1, ' '); /* HELLO */
if (!p) return 0;
p = strchr(p, ' '); /* HELLO, once more */
p = strchr(p + 1, ' '); /* HELLO, once more */
if (p)
*version = atoi(p);
return 1;