summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2015-01-15 12:38:57 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2015-01-15 14:13:49 +0100
commit975a900782528b57deafadc10457c7ffab0b9791 (patch)
treedf9ecc2143f9a6af383d9180d3667ee15b44a6c7 /src/udev
parent5e2de0eb1dff7bb86b40c16a0a9c9c4de33e77d1 (diff)
udev: fix NULL-ptr deref
Make sure we properly validate the return value of udev_device_get_sysattr_value(). It might be NULL for several reasons.
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/udev-builtin-input_id.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c
index a3289128b3..e6fd077260 100644
--- a/src/udev/udev-builtin-input_id.c
+++ b/src/udev/udev-builtin-input_id.c
@@ -4,6 +4,7 @@
* Copyright (C) 2009 Martin Pitt <martin.pitt@ubuntu.com>
* Portions Copyright (C) 2004 David Zeuthen, <david@fubar.dk>
* Copyright (C) 2011 Kay Sievers <kay@vrfy.org>
+ * Copyright (C) 2014 David Herrmann <dh.herrmann@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -48,12 +49,17 @@ static void get_cap_mask(struct udev_device *dev,
struct udev_device *pdev, const char* attr,
unsigned long *bitmask, size_t bitmask_size,
bool test) {
+ const char *v;
char text[4096];
unsigned i;
char* word;
unsigned long val;
- snprintf(text, sizeof(text), "%s", udev_device_get_sysattr_value(pdev, attr));
+ v = udev_device_get_sysattr_value(pdev, attr);
+ if (!v)
+ v = "";
+
+ snprintf(text, sizeof(text), "%s", v);
log_debug("%s raw kernel attribute: %s", attr, text);
memzero(bitmask, bitmask_size);