1
0
mirror of https://github.com/simh/simh.git synced 2026-01-14 15:45:18 +00:00

SCP: Fix expression evaluation of empty string to numeric value

Previously, numeric values incorrectly had a string representation of
"".  This allowed arbitrary equality comparisons to succeed in unexpected
ways.

Reported by Robert Sancho Villas
This commit is contained in:
Mark Pizzolato 2020-05-11 16:23:26 -07:00
parent 781c73fe21
commit c3fef9befc

2
scp.c
View File

@ -15057,6 +15057,7 @@ if (sim_isalpha (*data) || (*data == '_')) {
gptr = _sim_get_env_special (data, string, string_size - 1);
if (gptr) {
*svalue = strtotsv(string, &gptr, 0);
sprint_val (string, *svalue, 10, string_size - 1, PV_LEFTSIGN);
sim_debug (SIM_DBG_EXP_EVAL, &sim_scp_dev, "[Value: %s=%s]\n", data, string);
return ((*gptr == '\0') && (*string));
}
@ -15072,6 +15073,7 @@ if ((data[0] == '"') && (data_size > 1) && (data[data_size - 1] == '"'))
strlcpy (string, data, string_size);
if (string[0] == '\0') {
*svalue = strtotsv(data, &gptr, 0);
strlcpy (string, data, string_size);
sim_debug (SIM_DBG_EXP_EVAL, &sim_scp_dev, "[Value: %s=%s]\n", data, string);
return ((*gptr == '\0') && (*data));
}