summaryrefslogtreecommitdiff
path: root/libexslt
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2006-03-10 11:51:20 +0000
committerDaniel Veillard <veillard@src.gnome.org>2006-03-10 11:51:20 +0000
commita051b16deac9244704527cc3e0dbb5fc99fd6fdc (patch)
treeb363ffdbdea01adb2fa674d2dbaf066907ed757b /libexslt
parent8b32490926f21bfe6bacdd0c82adaf86660b9a38 (diff)
downloadlibxslt-a051b16deac9244704527cc3e0dbb5fc99fd6fdc.tar.gz
libxslt-a051b16deac9244704527cc3e0dbb5fc99fd6fdc.tar.bz2
libxslt-a051b16deac9244704527cc3e0dbb5fc99fd6fdc.zip
various assorted small cleanups based on the Coverity reports Daniel
* libexslt/crypto.c libexslt/date.c libexslt/saxon.c libxslt/attributes.c libxslt/imports.c libxslt/pattern.c libxslt/preproc.c libxslt/transform.c libxslt/variables.c libxslt/xslt.c libxslt/xsltutils.c: various assorted small cleanups based on the Coverity reports Daniel
Diffstat (limited to 'libexslt')
-rw-r--r--libexslt/crypto.c9
-rw-r--r--libexslt/date.c12
-rw-r--r--libexslt/saxon.c1
3 files changed, 20 insertions, 2 deletions
diff --git a/libexslt/crypto.c b/libexslt/crypto.c
index aac601c6..26271478 100644
--- a/libexslt/crypto.c
+++ b/libexslt/crypto.c
@@ -621,15 +621,24 @@ exsltCryptoRc4EncryptFunction (xmlXPathParserContextPtr ctxt, int nargs) {
/* encrypt it */
bin_len = str_len;
bin = xmlStrdup (str);
+ if (bin == NULL) {
+ xmlXPathReturnEmptyString (ctxt);
+ goto done;
+ }
PLATFORM_RC4_ENCRYPT (ctxt, padkey, str, str_len, bin, bin_len);
/* encode it */
hex_len = str_len * 2 + 1;
hex = xmlMallocAtomic (hex_len);
+ if (hex == NULL) {
+ xmlXPathReturnEmptyString (ctxt);
+ goto done;
+ }
exsltCryptoBin2Hex (bin, str_len, hex, hex_len);
xmlXPathReturnString (ctxt, hex);
+done:
if (key != NULL)
xmlFree (key);
if (str != NULL)
diff --git a/libexslt/date.c b/libexslt/date.c
index 37aa888b..59ca136d 100644
--- a/libexslt/date.c
+++ b/libexslt/date.c
@@ -553,12 +553,12 @@ _exsltDateParseTime (exsltDateValDatePtr dt, const xmlChar **str)
static int
_exsltDateParseTimeZone (exsltDateValDatePtr dt, const xmlChar **str)
{
- const xmlChar *cur = *str;
+ const xmlChar *cur;
int ret = 0;
if (str == NULL)
return -1;
-
+ cur = *str;
switch (*cur) {
case 0:
dt->tz_flag = 0;
@@ -1522,6 +1522,14 @@ _exsltDateAdd (exsltDateValPtr dt, exsltDateValPtr dur)
long tyr = r->year + (long)FQUOTIENT_RANGE((int)r->mon-1, 1, 13);
if (tyr == 0)
tyr--;
+ /*
+ * Coverity detected an overrun in daysInMonth
+ * of size 12 at position 12 with index variable "((r)->mon - 1)"
+ */
+ if (tmon < 0)
+ tmon = 0;
+ if (tmon > 12)
+ tmon = 12;
tempdays += MAX_DAYINMONTH(tyr, tmon);
carry = -1;
} else if (tempdays > (long)MAX_DAYINMONTH(r->year, r->mon)) {
diff --git a/libexslt/saxon.c b/libexslt/saxon.c
index f59bfb40..fcb1547a 100644
--- a/libexslt/saxon.c
+++ b/libexslt/saxon.c
@@ -221,6 +221,7 @@ exsltSaxonLineNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) {
if ((nodelist == NULL) || (nodelist->nodeNr <= 0)) {
xmlXPathFreeObject(obj);
valuePush(ctxt, xmlXPathNewFloat(-1));
+ return;
}
cur = nodelist->nodeTab[0];
for (i = 1;i < nodelist->nodeNr;i++) {