ps: that restored aix behavior is now even more robust

With the commit referenced below a nasty bug affecting
aix parsing was swatted. Beyond the bug, the logic was
enhanced to disallow commas in the format string since
they would otherwise be shown with their field's data.

However, there remained many characters other than ','
that could survive the edits to then be shown adjacent
to the data. Well, with this patch they won't anymore!

[ along the way we will no longer try to forgive the ]
[ use of a double '%%' prefix since that resulted in ]
[ display of one '%' and field code instead of data. ]

Reference(s):
. March, 2022 - restored aix bahavior
commit f0b7fd31db

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2022-04-04 00:00:00 -05:00 committed by Craig Small
parent f0b7fd31db
commit 99fed92200

View File

@ -128,11 +128,11 @@ static const char *aix_format_parse(sf_node *sfn){
items = 0; items = 0;
walk = sfn->sf; walk = sfn->sf;
/* state machine */ { /* state machine */ {
int c; int c = *walk++;
initial: initial:
c = *walk++;
if(c=='%') goto get_desc; if(c=='%') goto get_desc;
if(!c) goto looks_ok; if(!c) goto looks_ok;
if(c==' ') goto get_more;
if(c==',') goto aix_oops; if(c==',') goto aix_oops;
/* get_text: */ /* get_text: */
items++; items++;
@ -145,7 +145,8 @@ static const char *aix_format_parse(sf_node *sfn){
get_desc: get_desc:
items++; items++;
c = *walk++; c = *walk++;
if(c) goto initial; if(c&&c!=' ') goto initial;
return _("missing AIX field descriptor");
aix_oops: aix_oops:
return _("improper AIX field descriptor"); return _("improper AIX field descriptor");
looks_ok: looks_ok:
@ -163,7 +164,8 @@ static const char *aix_format_parse(sf_node *sfn){
if(*walk == '%'){ if(*walk == '%'){
const aix_struct *aix; const aix_struct *aix;
walk++; walk++;
if(*walk == '%') goto double_percent; if(*walk == '%')
return _("missing AIX field descriptor");
aix = search_aix_array(*walk); aix = search_aix_array(*walk);
walk++; walk++;
if(!aix){ if(!aix){
@ -179,11 +181,6 @@ static const char *aix_format_parse(sf_node *sfn){
size_t len; size_t len;
len = strcspn(walk, "%"); len = strcspn(walk, "%");
memcpy(buf,walk,len); memcpy(buf,walk,len);
if(0){
double_percent:
len = 1;
buf[0] = '%';
}
buf[len] = '\0'; buf[len] = '\0';
walk += len; walk += len;
fnode = malloc(sizeof(format_node)); fnode = malloc(sizeof(format_node));