Changes since 1.0.0:
- * Bug fixes, including fixes for CVE-2017-12958, CVE-2017-12959, and
- CVE-2017-12960.
+ * Bug fixes, including fixes for CVE-2017-12958, CVE-2017-12959,
+ CVE-2017-12960, and CVE-2017-12961.
Changes from 0.11.0 to 1.0.0:
#include <string.h>
#include "libpspp/array.h"
+#include "libpspp/compiler.h"
#include "libpspp/hash-functions.h"
#include "libpspp/i18n.h"
return CONST_CAST (struct attribute *, attr);
}
+/* Adds ATTR to SET. Succeeds and returns true if SET does not already contain
+ an attribute with the same name (matched case insensitively); otherwise
+ fails and returns false. On success only, ownership of ATTR is transferred
+ to SET. */
+bool
+attrset_try_add (struct attrset *set, struct attribute *attr)
+{
+ const char *name = attribute_get_name (attr);
+ if (attrset_lookup (set, name))
+ return false;
+ hmap_insert (&set->map, &attr->node, utf8_hash_case_string (name, 0));
+ return true;
+}
+
/* Adds ATTR to SET, which must not already contain an attribute
with the same name (matched case insensitively). Ownership of
ATTR is transferred to SET. */
void
attrset_add (struct attrset *set, struct attribute *attr)
{
- const char *name = attribute_get_name (attr);
- assert (attrset_lookup (set, name) == NULL);
- hmap_insert (&set->map, &attr->node, utf8_hash_case_string (name, 0));
+ bool ok UNUSED = attrset_try_add (set, attr);
+ assert (ok);
}
/* Deletes any attribute from SET that matches NAME
size_t attrset_count (const struct attrset *);
struct attribute *attrset_lookup (const struct attrset *, const char *);
+bool attrset_try_add (struct attrset *, struct attribute *);
void attrset_add (struct attrset *, struct attribute *);
void attrset_delete (struct attrset *, const char *);
void attrset_clear (struct attrset *);
break;
}
if (attrs != NULL)
- attrset_add (attrs, attr);
+ {
+ if (!attrset_try_add (attrs, attr))
+ {
+ text_warn (r, text, _("Duplicate attribute %s."),
+ attribute_get_name (attr));
+ attribute_destroy (attr);
+ }
+ }
else
attribute_destroy (attr);
}
done
AT_CLEANUP
+AT_SETUP([duplicate attribute name])
+AT_KEYWORDS([sack synthetic system file negative])
+AT_DATA([sys-file.sack], [dnl
+dnl File header.
+"$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
+2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
+
+dnl Variables.
+2; 0; 0; 0; 0x050800 *2; s8 "FIRSTVAR";
+
+dnl Data file attributes record.
+7; 17; 1; COUNT (
+"Attr1('value'"; i8 10; ")";
+"Attr1('value'"; i8 10; ")";
+);
+
+dnl Variable attributes record.
+7; 18; 1; COUNT (
+"FIRSTVAR:";
+ "fred('23'"; i8 10; ")";
+ "fred('23'"; i8 10; ")";
+);
+
+dnl Character encoding record.
+7; 20; 1; 12; "windows-1252";
+
+dnl Dictionary termination record.
+999; 0;
+])
+for variant in be le; do
+ AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
+ AT_DATA([sys-file.sps], [dnl
+GET FILE='sys-file.sav'.
+])
+ AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
+warning: `sys-file.sav' near offset 0xf6: Duplicate attribute Attr1.
+
+warning: `sys-file.sav' near offset 0x125: Duplicate attribute fred.
+])
+done
+AT_CLEANUP
+
AT_SETUP([bad variable name in long string value label])
AT_KEYWORDS([sack synthetic system file negative])
AT_DATA([sys-file.sack], [dnl