sys-file-reader: Disallow system and scratch long variable names too.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 3 Jan 2016 04:44:22 +0000 (20:44 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 3 Jan 2016 04:46:07 +0000 (20:46 -0800)
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
tests/data/sys-file-reader.at

index a1193de767dc4618d4a8a1bdf1b0e6f6d5e33341..8a747b7a57fc32fbd73465e70548aa48c1df9d47 100644 (file)
@@ -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 "
index 70cd84ea126ab3107a840608f14055634d910c34..7bd0ddf6449384448f9fb86c59ae71a3e7bdc8aa 100644 (file)
@@ -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