From 26d835f97534b20825b3121e326c288e994753f8 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 2 Jan 2016 20:44:22 -0800 Subject: [PATCH] sys-file-reader: Disallow system and scratch long variable names too. Before this commit, the system file reader disallowed system and scratch short variable names (e.g. names beginning with $ or #) but not as long variable names. This fixes the problem. Bug #46783. --- src/data/sys-file-reader.c | 5 +++-- tests/data/sys-file-reader.at | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index a1193de767..8a747b7a57 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-2000, 2006-2007, 2009-2015 Free Software Foundation, Inc. + Copyright (C) 1997-2000, 2006-2007, 2009-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2046,7 +2046,8 @@ parse_long_var_name_map (struct sfm_reader *r, while (read_variable_to_value_pair (r, dict, text, &var, &long_name)) { /* Validate long name. */ - if (!dict_id_is_valid (dict, long_name, false)) + if (!dict_id_is_valid (dict, long_name, false) + || long_name[0] == '$' || long_name[0] == '#') { sys_warn (r, record->pos, _("Long variable mapping from %s to invalid " diff --git a/tests/data/sys-file-reader.at b/tests/data/sys-file-reader.at index 70cd84ea12..7bd0ddf644 100644 --- a/tests/data/sys-file-reader.at +++ b/tests/data/sys-file-reader.at @@ -3064,6 +3064,8 @@ dnl Numeric variables. dnl Long variable names. 7; 13; 1; COUNT ( "LONGVARI=_Invalid"; i8 9; +"LONGVARI=$Invalid"; i8 9; +"LONGVARI=#Invalid"; i8 9; "LONGVA_A=LongVariableName"; i8 9; "LONGVA_B=LONGVARIABLENAME"; i8 9; ); @@ -3082,6 +3084,10 @@ GET FILE='sys-file.sav'. AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl warning: `sys-file.sav' near offset 0x138: Long variable mapping from LONGVARI to invalid variable name `_Invalid'. +warning: `sys-file.sav' near offset 0x138: Long variable mapping from LONGVARI to invalid variable name `$Invalid'. + +warning: `sys-file.sav' near offset 0x138: Long variable mapping from LONGVARI to invalid variable name `#Invalid'. + warning: `sys-file.sav' near offset 0x138: Duplicate long variable name `LONGVARIABLENAME'. ]) done -- 2.30.2