UAT: Allow extra fields.

If we encounter unexpected extra fields on a line, simply log a warning
and continue instead of returning an error. This allows forward
compatibility when we add a field to a UAT. We end up throwing away the
extra fields, but it's better than resetting the entire UAT. Fixes the
forward compatibility issue described in #17623.
This commit is contained in:
Gerald Combs 2021-11-06 13:52:01 -07:00
parent 6e4e4ebd50
commit 846b17ee9a
2 changed files with 11 additions and 2 deletions

View File

@ -2,6 +2,10 @@
/* Include this before everything else, for various large-file definitions */
#include "config.h"
#include <wireshark.h>
#define WS_LOG_DOMAIN LOG_DOMAIN_UAT
/* #define DEBUG_UAT_LOAD 1 */
}
/*
@ -214,6 +218,7 @@ typedef struct {
%}
quoted_string \042([^\042]|\134\042)*\042
extra_records_string (\042.*\042)
binstring ([0-9a-zA-Z][0-9a-zA-Z])*
separator [ \t]*,
newline [ \t]*[\r]?\n
@ -301,8 +306,10 @@ comment #[^\n]*\n
ERROR(("unexpected char '%s' while looking for field %s",yytext,yyextra->uat->fields[yyextra->colnum].name));
}
<END_OF_RECORD>{separator} {
ERROR(("more fields than required"));
<END_OF_RECORD>{separator}{extra_records_string} {
/* If we wanted to be really fancy we could retain the extra data. */
ws_log(WS_LOG_DOMAIN, LOG_LEVEL_WARNING, "%s:%d: More fields than required. Discarding '%s'.",
yyextra->uat->filename, yyextra->linenum, yytext);
}
<END_OF_RECORD>{newline} {

View File

@ -38,6 +38,8 @@
#define LOG_DOMAIN_QTUI "GUI"
#define LOG_DOMAIN_UAT "UAT"
/*
* Ascending order by priority needs to be maintained. Higher priorities have
* higher values.