diff options
author | Danny Kukawka <danny.kukawka@web.de> | 2009-11-26 22:33:05 +0100 |
---|---|---|
committer | Danny Kukawka <danny.kukawka@web.de> | 2009-11-26 22:33:05 +0100 |
commit | 92c858454d7d218493542b08164dc1702f077974 (patch) | |
tree | 9e132318ce36fd4b574ec5f1d4b8d74ade8d5e49 /hald | |
parent | 1849fb1dbc7aa905274134ce5cfa161840390a4a (diff) |
added check for NULL pointer to prevent trouble with strlen
Added some checks for NULL pointer in util.c to prevent
trouble with crash in strlen caused by NULL pointer.
Diffstat (limited to 'hald')
-rw-r--r-- | hald/util.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/hald/util.c b/hald/util.c index 59866867..d5346ec2 100644 --- a/hald/util.c +++ b/hald/util.c @@ -132,6 +132,9 @@ hal_util_get_parent_path (const gchar *path) guint len; gchar *parent_path; + if (path == NULL) + return NULL; + /* Find parent device by truncating our own path */ parent_path = g_strndup (path, HAL_PATH_MAX); len = strlen (parent_path); @@ -152,6 +155,9 @@ hal_util_get_normalized_path (const gchar *path1, const gchar *path2) const gchar *p2; gchar buf[HAL_PATH_MAX]; + if (path1 == NULL || path2 == NULL) + return NULL; + len1 = strlen (path1); len2 = strlen (path2); @@ -501,6 +507,9 @@ hal_util_grep_file (const gchar *directory, const gchar *file, const gchar *line result = NULL; + if (linestart == NULL) + return result; + /* TODO: use reuse and _grep_can_reuse parameters to avoid loading * the file again and again */ @@ -1200,7 +1209,7 @@ is_valid_interface_name (const char *name) { last_dot = NULL; - if (strlen(name) == 0) + if (name == NULL || strlen(name) == 0) return FALSE; end = name + strlen(name); |