From 34f28438feb87e8d8d46e8910c61624a5d2455da Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Sat, 23 Dec 2006 15:12:05 +0000 Subject: [PATCH] Fixed a bug in the XML parser that made pam_usb segfault if the value of the result node of the xpath query were empty. Fixed the volume probing system to abort if there's no UUID configured --- src/volume.c | 5 +++++ src/xpath.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/volume.c b/src/volume.c index 928cca3..202e443 100644 --- a/src/volume.c +++ b/src/volume.c @@ -79,6 +79,11 @@ static LibHalVolume *pusb_volume_probe(t_pusb_options *opts, int maxtries = 0; int i; + if (!*(opts->device.volume_uuid)) + { + log_debug("No UUID configured for device\n"); + return (NULL); + } log_debug("Searching for volume with uuid %s\n", opts->device.volume_uuid); maxtries = ((opts->probe_timeout * 1000000) / 250000); for (i = 0; i < maxtries; ++i) diff --git a/src/xpath.c b/src/xpath.c index 0e19abd..40ec8a6 100644 --- a/src/xpath.c +++ b/src/xpath.c @@ -65,6 +65,12 @@ int pusb_xpath_get_string(xmlDocPtr doc, const char *path, node = result->nodesetval->nodeTab[0]->xmlChildrenNode; result_string = xmlNodeListGetString(doc, node, 1); + if (!result_string) + { + xmlXPathFreeObject(result); + log_debug("Empty value for %s\n", path); + return (0); + } if (strlen((const char *)result_string) + 1 > size) { xmlFree(result_string);