From f8f0c044338c0084fd62321e935dd506ea9372ab 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 --- pam_usb/src/volume.c | 5 +++++ pam_usb/src/xpath.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/pam_usb/src/volume.c b/pam_usb/src/volume.c index 928cca3..202e443 100644 --- a/pam_usb/src/volume.c +++ b/pam_usb/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/pam_usb/src/xpath.c b/pam_usb/src/xpath.c index 0e19abd..40ec8a6 100644 --- a/pam_usb/src/xpath.c +++ b/pam_usb/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);