From 560701a881f119bcff6f0bd284c9f01c30c64ad3 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Wed, 25 May 2005 02:31:32 +0000 Subject: [PATCH] Reading of system files is now more robust against badly formed / specially crafted specimens. --- po/en_GB.po | 136 ++++++++++++++++++++++++------------------------ po/pspp.pot | 136 ++++++++++++++++++++++++------------------------ src/ChangeLog | 11 ++++ src/alloc.c | 27 +++++++--- src/alloc.h | 2 +- src/crosstabs.q | 2 +- src/get.c | 2 +- src/sfm-read.c | 29 +++++++++-- src/vars-prs.c | 2 +- 9 files changed, 197 insertions(+), 150 deletions(-) diff --git a/po/en_GB.po b/po/en_GB.po index e2c8dd23..b37eff2e 100644 --- a/po/en_GB.po +++ b/po/en_GB.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PSPP 0.3.1\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2005-05-21 12:51+0800\n" +"POT-Creation-Date: 2005-05-23 12:08+0800\n" "PO-Revision-Date: 2004-01-23 13:04+0800\n" "Last-Translator: John Darrington \n" "Language-Team: John Darrington \n" @@ -84,12 +84,12 @@ msgid "Variable %s is %s in target file, but %s in source file." msgstr "" #: src/apply-dict.c:71 src/apply-dict.c:72 src/format.c:236 -#: src/sfm-read.c:1011 src/sfm-read.c:1149 src/sfm-read.c:1150 +#: src/sfm-read.c:1013 src/sfm-read.c:1151 src/sfm-read.c:1152 msgid "string" msgstr "" #: src/apply-dict.c:71 src/apply-dict.c:72 src/format.c:236 -#: src/sfm-read.c:1011 src/sfm-read.c:1149 src/sfm-read.c:1150 +#: src/sfm-read.c:1013 src/sfm-read.c:1151 src/sfm-read.c:1152 msgid "numeric" msgstr "" @@ -1495,11 +1495,11 @@ msgstr "" msgid "%s variables are not compatible with %s format %s." msgstr "" -#: src/format.c:235 src/pfm-read.c:473 src/sfm-read.c:1009 src/sfm-read.c:1018 +#: src/format.c:235 src/pfm-read.c:473 src/sfm-read.c:1011 src/sfm-read.c:1020 msgid "String" msgstr "" -#: src/format.c:235 src/pfm-read.c:473 src/sfm-read.c:1009 src/sfm-read.c:1018 +#: src/format.c:235 src/pfm-read.c:473 src/sfm-read.c:1011 src/sfm-read.c:1020 msgid "Numeric" msgstr "" @@ -2603,12 +2603,12 @@ msgstr "" msgid "Bad time string length %d." msgstr "" -#: src/pfm-read.c:465 src/sfm-read.c:1001 +#: src/pfm-read.c:465 src/sfm-read.c:1003 #, c-format msgid "%s: Bad format specifier byte (%d)." msgstr "" -#: src/pfm-read.c:472 src/sfm-read.c:1017 +#: src/pfm-read.c:472 src/sfm-read.c:1019 #, c-format msgid "%s variable %s has invalid format specifier %s." msgstr "" @@ -3024,130 +3024,130 @@ msgstr "" msgid "Only last instance of this command is in effect." msgstr "" -#: src/sfm-read.c:130 +#: src/sfm-read.c:129 msgid "corrupt system file: " msgstr "" -#: src/sfm-read.c:149 src/sfm-write.c:919 +#: src/sfm-read.c:148 src/sfm-write.c:919 #, c-format msgid "%s: Closing system file: %s." msgstr "" -#: src/sfm-read.c:236 +#: src/sfm-read.c:234 #, c-format msgid "" "An error occurred while opening \"%s\" for reading as a system file: %s." msgstr "" -#: src/sfm-read.c:253 +#: src/sfm-read.c:252 #, c-format msgid "" "%s: Index of weighting variable (%d) is not between 0 and number of elements " "per case (%d)." msgstr "" -#: src/sfm-read.c:262 +#: src/sfm-read.c:261 #, c-format msgid "" "%s: Weighting variable may not be a continuation of a long string variable." msgstr "" -#: src/sfm-read.c:265 +#: src/sfm-read.c:264 #, c-format msgid "%s: Weighting variable may not be a string variable." msgstr "" -#: src/sfm-read.c:290 +#: src/sfm-read.c:289 #, c-format msgid "" "%s: Orphaned variable index record (type 4). Type 4 records must always " "immediately follow type 3 records." msgstr "" -#: src/sfm-read.c:348 +#: src/sfm-read.c:347 #, c-format msgid "%s: Invalid subrecord length. Record: 7; Subrecord: 11" msgstr "" -#: src/sfm-read.c:402 +#: src/sfm-read.c:401 #, c-format msgid "%s: Trailing garbage in long variable name map." msgstr "" -#: src/sfm-read.c:409 +#: src/sfm-read.c:408 #, c-format msgid "%s: Long variable mapping to invalid variable name `%s'." msgstr "" -#: src/sfm-read.c:419 +#: src/sfm-read.c:418 #, c-format msgid "%s: Long variable mapping for nonexistent variable %s." msgstr "" -#: src/sfm-read.c:447 +#: src/sfm-read.c:446 #, c-format msgid "%s: Unrecognized record type 7, subtype %d encountered in system file." msgstr "" -#: src/sfm-read.c:472 +#: src/sfm-read.c:471 #, c-format msgid "%s: Unrecognized record type %d." msgstr "" -#: src/sfm-read.c:504 +#: src/sfm-read.c:503 #, c-format msgid "" "%s: Bad size (%d) or count (%d) field on record type 7, subtype 3.\tExpected " "size %d, count 8." msgstr "" -#: src/sfm-read.c:515 +#: src/sfm-read.c:514 #, c-format msgid "" "%s: Floating-point representation in system file is not IEEE-754. PSPP " "cannot convert between floating-point formats." msgstr "" -#: src/sfm-read.c:531 +#: src/sfm-read.c:530 #, c-format msgid "" "%s: File-indicated endianness (%s) does not match endianness intuited from " "file header (%s)." msgstr "" -#: src/sfm-read.c:534 src/sfm-read.c:535 +#: src/sfm-read.c:533 src/sfm-read.c:534 msgid "big-endian" msgstr "" -#: src/sfm-read.c:534 src/sfm-read.c:535 +#: src/sfm-read.c:533 src/sfm-read.c:534 msgid "little-endian" msgstr "" -#: src/sfm-read.c:536 +#: src/sfm-read.c:535 msgid "unknown" msgstr "" -#: src/sfm-read.c:540 +#: src/sfm-read.c:539 #, c-format msgid "%s: File-indicated character representation code (%s) is not ASCII." msgstr "" -#: src/sfm-read.c:544 +#: src/sfm-read.c:543 msgid "DEC Kanji" msgstr "" -#: src/sfm-read.c:544 src/sysfile-info.c:115 +#: src/sfm-read.c:543 src/sysfile-info.c:115 msgid "Unknown" msgstr "" -#: src/sfm-read.c:560 +#: src/sfm-read.c:559 #, c-format msgid "" "%s: Bad size (%d) or count (%d) field on record type 7, subtype 4.\tExpected " "size %d, count 8." msgstr "" -#: src/sfm-read.c:575 +#: src/sfm-read.c:574 #, c-format msgid "" "%s: File-indicated value is different from internal value for at least one " @@ -3155,210 +3155,210 @@ msgid "" "%g; LOWEST: %g, %g." msgstr "" -#: src/sfm-read.c:602 +#: src/sfm-read.c:601 #, c-format msgid "" "%s: Bad magic. Proper system files begin with the four characters `$FL2'. " "This file will not be read." msgstr "" -#: src/sfm-read.c:644 +#: src/sfm-read.c:643 #, c-format msgid "" "%s: File layout code has unexpected value %d. Value should be 2, in big-" "endian or little-endian format." msgstr "" -#: src/sfm-read.c:672 +#: src/sfm-read.c:671 #, c-format msgid "%s: Number of cases in file (%ld) is not between -1 and %d." msgstr "" -#: src/sfm-read.c:677 +#: src/sfm-read.c:676 #, c-format msgid "%s: Compression bias (%g) is not the usual value of 100." msgstr "" -#: src/sfm-read.c:794 +#: src/sfm-read.c:799 #, c-format msgid "" "%s: position %d: String variable does not have proper number of continuation " "records." msgstr "" -#: src/sfm-read.c:803 +#: src/sfm-read.c:810 #, c-format msgid "%s: position %d: Superfluous long string continuation record." msgstr "" -#: src/sfm-read.c:809 +#: src/sfm-read.c:816 #, c-format msgid "%s: position %d: Bad variable type code %d." msgstr "" -#: src/sfm-read.c:812 +#: src/sfm-read.c:819 #, c-format msgid "%s: position %d: Variable label indicator field is not 0 or 1." msgstr "" -#: src/sfm-read.c:816 +#: src/sfm-read.c:823 #, c-format msgid "" "%s: position %d: Missing value indicator field is not -3, -2, 0, 1, 2, or 3." msgstr "" -#: src/sfm-read.c:822 +#: src/sfm-read.c:829 #, c-format msgid "%s: position %d: Variable name begins with invalid character." msgstr "" -#: src/sfm-read.c:826 +#: src/sfm-read.c:833 #, c-format msgid "%s: position %d: Variable name begins with lowercase letter %c." msgstr "" -#: src/sfm-read.c:830 +#: src/sfm-read.c:837 #, c-format msgid "" "%s: position %d: Variable name begins with octothorpe (`#'). Scratch " "variables should not appear in system files." msgstr "" -#: src/sfm-read.c:845 +#: src/sfm-read.c:852 #, c-format msgid "%s: position %d: Variable name character %d is lowercase letter %c." msgstr "" -#: src/sfm-read.c:854 +#: src/sfm-read.c:861 #, c-format msgid "" "%s: position %d: character `\\%03o' (%c) is not valid in a variable name." msgstr "" -#: src/sfm-read.c:863 +#: src/sfm-read.c:870 #, c-format msgid "%s: Duplicate variable name `%s' within system file." msgstr "" -#: src/sfm-read.c:885 +#: src/sfm-read.c:892 #, c-format msgid "%s: Variable %s indicates variable label of invalid length %d." msgstr "" -#: src/sfm-read.c:905 +#: src/sfm-read.c:912 #, c-format msgid "%s: Long string variable %s may not have missing values." msgstr "" -#: src/sfm-read.c:930 +#: src/sfm-read.c:937 #, c-format msgid "" "%s: String variable %s may not have missing values specified as a range." msgstr "" -#: src/sfm-read.c:978 +#: src/sfm-read.c:979 #, c-format msgid "%s: Long string continuation records omitted at end of dictionary." msgstr "" -#: src/sfm-read.c:983 +#: src/sfm-read.c:984 #, c-format msgid "" "%s: System file header indicates %d variable positions but %d were read from " "file." msgstr "" -#: src/sfm-read.c:1007 +#: src/sfm-read.c:1009 #, c-format msgid "%s: %s variable %s has %s format specifier %s." msgstr "" -#: src/sfm-read.c:1095 +#: src/sfm-read.c:1097 #, c-format msgid "" "%s: Variable index record (type 4) does not immediately follow value label " "record (type 3) as it should." msgstr "" -#: src/sfm-read.c:1106 +#: src/sfm-read.c:1108 #, c-format msgid "" "%s: Number of variables associated with a value label (%d) is not between 1 " "and the number of variables (%d)." msgstr "" -#: src/sfm-read.c:1122 +#: src/sfm-read.c:1124 #, c-format msgid "" "%s: Variable index associated with value label (%d) is not between 1 and the " "number of values (%d)." msgstr "" -#: src/sfm-read.c:1129 +#: src/sfm-read.c:1131 #, c-format msgid "" "%s: Variable index associated with value label (%d) refers to a continuation " "of a string variable, not to an actual variable." msgstr "" -#: src/sfm-read.c:1134 +#: src/sfm-read.c:1136 #, c-format msgid "%s: Value labels are not allowed on long string variables (%s)." msgstr "" -#: src/sfm-read.c:1145 +#: src/sfm-read.c:1147 #, c-format msgid "" "%s: Variables associated with value label are not all of identical type. " "Variable %s has %s type, but variable %s has %s type." msgstr "" -#: src/sfm-read.c:1186 +#: src/sfm-read.c:1188 #, c-format msgid "%s: File contains duplicate label for value %g for variable %s." msgstr "" -#: src/sfm-read.c:1190 +#: src/sfm-read.c:1192 #, c-format msgid "%s: File contains duplicate label for value `%.*s' for variable %s." msgstr "" -#: src/sfm-read.c:1232 src/sfm-read.c:1509 +#: src/sfm-read.c:1234 src/sfm-read.c:1511 #, c-format msgid "%s: Reading system file: %s." msgstr "" -#: src/sfm-read.c:1235 src/sfm-read.c:1350 src/sfm-read.c:1392 +#: src/sfm-read.c:1237 src/sfm-read.c:1352 src/sfm-read.c:1394 #, c-format msgid "%s: Unexpected end of file." msgstr "" -#: src/sfm-read.c:1250 +#: src/sfm-read.c:1252 #, c-format msgid "%s: Seeking system file: %s." msgstr "" -#: src/sfm-read.c:1265 +#: src/sfm-read.c:1267 #, c-format msgid "%s: System file contains multiple type 6 (document) records." msgstr "" -#: src/sfm-read.c:1271 +#: src/sfm-read.c:1273 #, c-format msgid "%s: Number of document lines (%ld) must be greater than 0." msgstr "" -#: src/sfm-read.c:1303 +#: src/sfm-read.c:1305 #, c-format msgid "%s: Error reading file: %s." msgstr "" -#: src/sfm-read.c:1340 +#: src/sfm-read.c:1342 #, c-format msgid "%s: Compressed data is corrupted. Data ends in partial case." msgstr "" -#: src/sfm-read.c:1512 +#: src/sfm-read.c:1514 #, c-format msgid "%s: Partial record at end of system file." msgstr "" diff --git a/po/pspp.pot b/po/pspp.pot index 8560e09b..61387a3a 100644 --- a/po/pspp.pot +++ b/po/pspp.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2005-05-21 12:51+0800\n" +"POT-Creation-Date: 2005-05-23 12:08+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -85,12 +85,12 @@ msgid "Variable %s is %s in target file, but %s in source file." msgstr "" #: src/apply-dict.c:71 src/apply-dict.c:72 src/format.c:236 -#: src/sfm-read.c:1011 src/sfm-read.c:1149 src/sfm-read.c:1150 +#: src/sfm-read.c:1013 src/sfm-read.c:1151 src/sfm-read.c:1152 msgid "string" msgstr "" #: src/apply-dict.c:71 src/apply-dict.c:72 src/format.c:236 -#: src/sfm-read.c:1011 src/sfm-read.c:1149 src/sfm-read.c:1150 +#: src/sfm-read.c:1013 src/sfm-read.c:1151 src/sfm-read.c:1152 msgid "numeric" msgstr "" @@ -1496,11 +1496,11 @@ msgstr "" msgid "%s variables are not compatible with %s format %s." msgstr "" -#: src/format.c:235 src/pfm-read.c:473 src/sfm-read.c:1009 src/sfm-read.c:1018 +#: src/format.c:235 src/pfm-read.c:473 src/sfm-read.c:1011 src/sfm-read.c:1020 msgid "String" msgstr "" -#: src/format.c:235 src/pfm-read.c:473 src/sfm-read.c:1009 src/sfm-read.c:1018 +#: src/format.c:235 src/pfm-read.c:473 src/sfm-read.c:1011 src/sfm-read.c:1020 msgid "Numeric" msgstr "" @@ -2604,12 +2604,12 @@ msgstr "" msgid "Bad time string length %d." msgstr "" -#: src/pfm-read.c:465 src/sfm-read.c:1001 +#: src/pfm-read.c:465 src/sfm-read.c:1003 #, c-format msgid "%s: Bad format specifier byte (%d)." msgstr "" -#: src/pfm-read.c:472 src/sfm-read.c:1017 +#: src/pfm-read.c:472 src/sfm-read.c:1019 #, c-format msgid "%s variable %s has invalid format specifier %s." msgstr "" @@ -3025,130 +3025,130 @@ msgstr "" msgid "Only last instance of this command is in effect." msgstr "" -#: src/sfm-read.c:130 +#: src/sfm-read.c:129 msgid "corrupt system file: " msgstr "" -#: src/sfm-read.c:149 src/sfm-write.c:919 +#: src/sfm-read.c:148 src/sfm-write.c:919 #, c-format msgid "%s: Closing system file: %s." msgstr "" -#: src/sfm-read.c:236 +#: src/sfm-read.c:234 #, c-format msgid "" "An error occurred while opening \"%s\" for reading as a system file: %s." msgstr "" -#: src/sfm-read.c:253 +#: src/sfm-read.c:252 #, c-format msgid "" "%s: Index of weighting variable (%d) is not between 0 and number of elements " "per case (%d)." msgstr "" -#: src/sfm-read.c:262 +#: src/sfm-read.c:261 #, c-format msgid "" "%s: Weighting variable may not be a continuation of a long string variable." msgstr "" -#: src/sfm-read.c:265 +#: src/sfm-read.c:264 #, c-format msgid "%s: Weighting variable may not be a string variable." msgstr "" -#: src/sfm-read.c:290 +#: src/sfm-read.c:289 #, c-format msgid "" "%s: Orphaned variable index record (type 4). Type 4 records must always " "immediately follow type 3 records." msgstr "" -#: src/sfm-read.c:348 +#: src/sfm-read.c:347 #, c-format msgid "%s: Invalid subrecord length. Record: 7; Subrecord: 11" msgstr "" -#: src/sfm-read.c:402 +#: src/sfm-read.c:401 #, c-format msgid "%s: Trailing garbage in long variable name map." msgstr "" -#: src/sfm-read.c:409 +#: src/sfm-read.c:408 #, c-format msgid "%s: Long variable mapping to invalid variable name `%s'." msgstr "" -#: src/sfm-read.c:419 +#: src/sfm-read.c:418 #, c-format msgid "%s: Long variable mapping for nonexistent variable %s." msgstr "" -#: src/sfm-read.c:447 +#: src/sfm-read.c:446 #, c-format msgid "%s: Unrecognized record type 7, subtype %d encountered in system file." msgstr "" -#: src/sfm-read.c:472 +#: src/sfm-read.c:471 #, c-format msgid "%s: Unrecognized record type %d." msgstr "" -#: src/sfm-read.c:504 +#: src/sfm-read.c:503 #, c-format msgid "" "%s: Bad size (%d) or count (%d) field on record type 7, subtype 3.\tExpected " "size %d, count 8." msgstr "" -#: src/sfm-read.c:515 +#: src/sfm-read.c:514 #, c-format msgid "" "%s: Floating-point representation in system file is not IEEE-754. PSPP " "cannot convert between floating-point formats." msgstr "" -#: src/sfm-read.c:531 +#: src/sfm-read.c:530 #, c-format msgid "" "%s: File-indicated endianness (%s) does not match endianness intuited from " "file header (%s)." msgstr "" -#: src/sfm-read.c:534 src/sfm-read.c:535 +#: src/sfm-read.c:533 src/sfm-read.c:534 msgid "big-endian" msgstr "" -#: src/sfm-read.c:534 src/sfm-read.c:535 +#: src/sfm-read.c:533 src/sfm-read.c:534 msgid "little-endian" msgstr "" -#: src/sfm-read.c:536 +#: src/sfm-read.c:535 msgid "unknown" msgstr "" -#: src/sfm-read.c:540 +#: src/sfm-read.c:539 #, c-format msgid "%s: File-indicated character representation code (%s) is not ASCII." msgstr "" -#: src/sfm-read.c:544 +#: src/sfm-read.c:543 msgid "DEC Kanji" msgstr "" -#: src/sfm-read.c:544 src/sysfile-info.c:115 +#: src/sfm-read.c:543 src/sysfile-info.c:115 msgid "Unknown" msgstr "" -#: src/sfm-read.c:560 +#: src/sfm-read.c:559 #, c-format msgid "" "%s: Bad size (%d) or count (%d) field on record type 7, subtype 4.\tExpected " "size %d, count 8." msgstr "" -#: src/sfm-read.c:575 +#: src/sfm-read.c:574 #, c-format msgid "" "%s: File-indicated value is different from internal value for at least one " @@ -3156,210 +3156,210 @@ msgid "" "%g; LOWEST: %g, %g." msgstr "" -#: src/sfm-read.c:602 +#: src/sfm-read.c:601 #, c-format msgid "" "%s: Bad magic. Proper system files begin with the four characters `$FL2'. " "This file will not be read." msgstr "" -#: src/sfm-read.c:644 +#: src/sfm-read.c:643 #, c-format msgid "" "%s: File layout code has unexpected value %d. Value should be 2, in big-" "endian or little-endian format." msgstr "" -#: src/sfm-read.c:672 +#: src/sfm-read.c:671 #, c-format msgid "%s: Number of cases in file (%ld) is not between -1 and %d." msgstr "" -#: src/sfm-read.c:677 +#: src/sfm-read.c:676 #, c-format msgid "%s: Compression bias (%g) is not the usual value of 100." msgstr "" -#: src/sfm-read.c:794 +#: src/sfm-read.c:799 #, c-format msgid "" "%s: position %d: String variable does not have proper number of continuation " "records." msgstr "" -#: src/sfm-read.c:803 +#: src/sfm-read.c:810 #, c-format msgid "%s: position %d: Superfluous long string continuation record." msgstr "" -#: src/sfm-read.c:809 +#: src/sfm-read.c:816 #, c-format msgid "%s: position %d: Bad variable type code %d." msgstr "" -#: src/sfm-read.c:812 +#: src/sfm-read.c:819 #, c-format msgid "%s: position %d: Variable label indicator field is not 0 or 1." msgstr "" -#: src/sfm-read.c:816 +#: src/sfm-read.c:823 #, c-format msgid "" "%s: position %d: Missing value indicator field is not -3, -2, 0, 1, 2, or 3." msgstr "" -#: src/sfm-read.c:822 +#: src/sfm-read.c:829 #, c-format msgid "%s: position %d: Variable name begins with invalid character." msgstr "" -#: src/sfm-read.c:826 +#: src/sfm-read.c:833 #, c-format msgid "%s: position %d: Variable name begins with lowercase letter %c." msgstr "" -#: src/sfm-read.c:830 +#: src/sfm-read.c:837 #, c-format msgid "" "%s: position %d: Variable name begins with octothorpe (`#'). Scratch " "variables should not appear in system files." msgstr "" -#: src/sfm-read.c:845 +#: src/sfm-read.c:852 #, c-format msgid "%s: position %d: Variable name character %d is lowercase letter %c." msgstr "" -#: src/sfm-read.c:854 +#: src/sfm-read.c:861 #, c-format msgid "" "%s: position %d: character `\\%03o' (%c) is not valid in a variable name." msgstr "" -#: src/sfm-read.c:863 +#: src/sfm-read.c:870 #, c-format msgid "%s: Duplicate variable name `%s' within system file." msgstr "" -#: src/sfm-read.c:885 +#: src/sfm-read.c:892 #, c-format msgid "%s: Variable %s indicates variable label of invalid length %d." msgstr "" -#: src/sfm-read.c:905 +#: src/sfm-read.c:912 #, c-format msgid "%s: Long string variable %s may not have missing values." msgstr "" -#: src/sfm-read.c:930 +#: src/sfm-read.c:937 #, c-format msgid "" "%s: String variable %s may not have missing values specified as a range." msgstr "" -#: src/sfm-read.c:978 +#: src/sfm-read.c:979 #, c-format msgid "%s: Long string continuation records omitted at end of dictionary." msgstr "" -#: src/sfm-read.c:983 +#: src/sfm-read.c:984 #, c-format msgid "" "%s: System file header indicates %d variable positions but %d were read from " "file." msgstr "" -#: src/sfm-read.c:1007 +#: src/sfm-read.c:1009 #, c-format msgid "%s: %s variable %s has %s format specifier %s." msgstr "" -#: src/sfm-read.c:1095 +#: src/sfm-read.c:1097 #, c-format msgid "" "%s: Variable index record (type 4) does not immediately follow value label " "record (type 3) as it should." msgstr "" -#: src/sfm-read.c:1106 +#: src/sfm-read.c:1108 #, c-format msgid "" "%s: Number of variables associated with a value label (%d) is not between 1 " "and the number of variables (%d)." msgstr "" -#: src/sfm-read.c:1122 +#: src/sfm-read.c:1124 #, c-format msgid "" "%s: Variable index associated with value label (%d) is not between 1 and the " "number of values (%d)." msgstr "" -#: src/sfm-read.c:1129 +#: src/sfm-read.c:1131 #, c-format msgid "" "%s: Variable index associated with value label (%d) refers to a continuation " "of a string variable, not to an actual variable." msgstr "" -#: src/sfm-read.c:1134 +#: src/sfm-read.c:1136 #, c-format msgid "%s: Value labels are not allowed on long string variables (%s)." msgstr "" -#: src/sfm-read.c:1145 +#: src/sfm-read.c:1147 #, c-format msgid "" "%s: Variables associated with value label are not all of identical type. " "Variable %s has %s type, but variable %s has %s type." msgstr "" -#: src/sfm-read.c:1186 +#: src/sfm-read.c:1188 #, c-format msgid "%s: File contains duplicate label for value %g for variable %s." msgstr "" -#: src/sfm-read.c:1190 +#: src/sfm-read.c:1192 #, c-format msgid "%s: File contains duplicate label for value `%.*s' for variable %s." msgstr "" -#: src/sfm-read.c:1232 src/sfm-read.c:1509 +#: src/sfm-read.c:1234 src/sfm-read.c:1511 #, c-format msgid "%s: Reading system file: %s." msgstr "" -#: src/sfm-read.c:1235 src/sfm-read.c:1350 src/sfm-read.c:1392 +#: src/sfm-read.c:1237 src/sfm-read.c:1352 src/sfm-read.c:1394 #, c-format msgid "%s: Unexpected end of file." msgstr "" -#: src/sfm-read.c:1250 +#: src/sfm-read.c:1252 #, c-format msgid "%s: Seeking system file: %s." msgstr "" -#: src/sfm-read.c:1265 +#: src/sfm-read.c:1267 #, c-format msgid "%s: System file contains multiple type 6 (document) records." msgstr "" -#: src/sfm-read.c:1271 +#: src/sfm-read.c:1273 #, c-format msgid "%s: Number of document lines (%ld) must be greater than 0." msgstr "" -#: src/sfm-read.c:1303 +#: src/sfm-read.c:1305 #, c-format msgid "%s: Error reading file: %s." msgstr "" -#: src/sfm-read.c:1340 +#: src/sfm-read.c:1342 #, c-format msgid "%s: Compressed data is corrupted. Data ends in partial case." msgstr "" -#: src/sfm-read.c:1512 +#: src/sfm-read.c:1514 #, c-format msgid "%s: Partial record at end of system file." msgstr "" diff --git a/src/ChangeLog b/src/ChangeLog index 5bde5cc2..ac2affb8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +Wed May 25 10:27:02 WST 2005 John Darrington + + * alloc.c alloc.h: (xcalloc) changed signature to imitate the + POSIX calloc function. + + * crosstabs.q get.c vars-prs.c: Updated calls to xcalloc to + reflect new signature. + + * sfm-read.c: Now much more robust in the face of badly formed + system files. + Mon May 23 11:57:31 WST 2005 John Darrington *sfm-read.c: Fixed some bugs regarding long string continuation diff --git a/src/alloc.c b/src/alloc.c index b25e7dc9..8d1e39a6 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -43,18 +43,31 @@ xmalloc (size_t size) return vp; } -/* Allocates a block of SIZE bytes, fill it with all-bits-0, and - returns it. - If SIZE is 0, returns a null pointer. - Aborts if unsuccessful. */ + +/* Allocates a continous block of N_MEMB by SIZE elements, with all + bits set to 0. + Aborts if unsuccessful. +*/ void * -xcalloc (size_t size) +xcalloc (size_t n_memb, size_t size) { - void *vp = xmalloc (size); - memset (vp, 0, size); + const size_t prod = size * n_memb; + void *vp = 0; + + if (prod == 0) + return NULL; + + /* Trap overflow errors */ + assert ( prod >= size ); + assert ( prod >= n_memb ) ; + + vp = xmalloc ( prod ); + memset (vp, 0, prod); return vp; } + + /* If SIZE is 0, then block PTR is freed and a null pointer is returned. Otherwise, if PTR is a null pointer, then a new block is allocated diff --git a/src/alloc.h b/src/alloc.h index 979d2da0..c14bc7a9 100644 --- a/src/alloc.h +++ b/src/alloc.h @@ -24,7 +24,7 @@ /* malloc() wrapper functions. */ void *xmalloc (size_t size); -void *xcalloc (size_t size); +void *xcalloc (size_t n_memb, size_t size); void *xrealloc (void *ptr, size_t size); char *xstrdup (const char *s); void out_of_memory (void) NO_RETURN; diff --git a/src/crosstabs.q b/src/crosstabs.q index 95f3dc33..62ba0a3a 100644 --- a/src/crosstabs.q +++ b/src/crosstabs.q @@ -338,7 +338,7 @@ crs_custom_tables (struct cmd_crosstabs *cmd UNUSED) } { - int *by_iter = xcalloc (sizeof *by_iter * n_by); + int *by_iter = xcalloc (n_by, sizeof *by_iter); int i; xtab = xrealloc (xtab, sizeof *xtab * (nxtab + nx)); diff --git a/src/get.c b/src/get.c index 3300ae64..0658ab24 100644 --- a/src/get.c +++ b/src/get.c @@ -1030,7 +1030,7 @@ cmd_match_files (void) if (mtf.sink->class->open != NULL) mtf.sink->class->open (mtf.sink); - mtf.seq_nums = xcalloc (dict_get_var_cnt (mtf.dict) * sizeof *mtf.seq_nums); + mtf.seq_nums = xcalloc (dict_get_var_cnt (mtf.dict), sizeof *mtf.seq_nums); case_create (&mtf.mtf_case, dict_get_next_value_idx (mtf.dict)); mtf_read_nonactive_records (&mtf); diff --git a/src/sfm-read.c b/src/sfm-read.c index 12df275e..fef4eb5c 100644 --- a/src/sfm-read.c +++ b/src/sfm-read.c @@ -342,7 +342,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, { const int n_vars = data.count / 3 ; int i; - if ( data.count % 3 ) + if ( data.count % 3 || n_vars > dict_get_var_cnt(*dict) ) { msg (MW, _("%s: Invalid subrecord length. " "Record: 7; Subrecord: 11"), @@ -350,7 +350,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, skip = 1; } - for ( i = 0 ; i < n_vars ; ++i ) + for ( i = 0 ; i < min(n_vars, dict_get_var_cnt(*dict)) ; ++i ) { struct { @@ -421,6 +421,16 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, break; } + /* Identify any duplicates. */ + if ( compare_var_names(short_name, long_name, 0) && + NULL != dict_lookup_var (*dict, long_name)) + { + lose ((ME, _("%s: Duplicate long variable name `%s' " + "within system file."), + handle_get_filename (r->fh), long_name)); + break; + } + /* Set long name. Renaming a variable may clear the short name, but we want to retain it, so @@ -864,11 +874,17 @@ read_variables (struct sfm_reader *r, } name[j] = 0; + if ( ! var_is_valid_name(name, false) ) + lose ((ME, _("%s: Invalid variable name `%s' within system file."), + handle_get_filename (r->fh), name)); + /* Create variable. */ + vv = (*var_by_idx)[i] = dict_create_var (dict, name, sv.type); if (vv == NULL) lose ((ME, _("%s: Duplicate variable name `%s' within system file."), handle_get_filename (r->fh), name)); + var_set_short_name (vv, vv->name); /* Case reading data. */ @@ -1057,8 +1073,15 @@ read_value_labels (struct sfm_reader *r, if (r->reverse_endian) bswap_int32 (&n_labels); + if ( n_labels >= ((int32) ~0) / sizeof *labels) + { + corrupt_msg(MW, _("%s: Invalid number of labels: %d. Ignoring labels."), + handle_get_filename (r->fh), n_labels); + n_labels = 0; + } + /* Allocate memory. */ - labels = xmalloc (n_labels * sizeof *labels); + labels = xcalloc (n_labels , sizeof *labels); for (i = 0; i < n_labels; i++) labels[i].label = NULL; diff --git a/src/vars-prs.c b/src/vars-prs.c index 23f37010..1773e4d8 100644 --- a/src/vars-prs.c +++ b/src/vars-prs.c @@ -259,7 +259,7 @@ parse_var_set_vars (const struct var_set *vs, { int i; - included = xcalloc (var_set_get_cnt (vs)); + included = xcalloc (var_set_get_cnt (vs), sizeof *included); for (i = 0; i < *nv; i++) included[(*v)[i]->index] = 1; } -- 2.30.2