[PATCH 1/2] pdbtool: Bail out on errors even if validating only.
When run with the --validate flag, and an error is detected, short circuit to the next file, instead of running the rest of the validation with garbled data. Reported-by: Peter Czanik <czanik@balabit.hu> Signed-off-by: Gergely Nagy <algernon@balabit.hu> --- modules/dbparser/pdbtool.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/modules/dbparser/pdbtool.c b/modules/dbparser/pdbtool.c index 13bc7d4..c2f9117 100644 --- a/modules/dbparser/pdbtool.c +++ b/modules/dbparser/pdbtool.c @@ -694,12 +694,14 @@ pdbtool_test(int argc, char *argv[]) { fprintf(stderr, "%s: Unable to detect patterndb version, please write the <patterndb> tag on a single line\n", argv[arg_pos]); failed_to_validate = TRUE; + continue; } g_snprintf(cmd, sizeof(cmd), "xmllint --noout --nonet --schema %s/patterndb-%d.xsd %s", PATH_XSDDIR, version, argv[arg_pos]); if (system(cmd) != 0) { fprintf(stderr, "%s: xmllint returned an error, the executed command was: %s", argv[arg_pos], cmd); failed_to_validate = TRUE; + continue; } } -- 1.7.7.1
When run in test mode (pdbtool test), check that a file exists, before trying to load it, and return a sensible error message in case it does not. Reported-By: Peter Czanik <czanik@balabit.hu> Signed-off-by: Gergely Nagy <algernon@balabit.hu> --- modules/dbparser/pdbtool.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/modules/dbparser/pdbtool.c b/modules/dbparser/pdbtool.c index c2f9117..b11a91a 100644 --- a/modules/dbparser/pdbtool.c +++ b/modules/dbparser/pdbtool.c @@ -684,6 +684,13 @@ pdbtool_test(int argc, char *argv[]) for (arg_pos = 1; arg_pos < argc; arg_pos++) { + if (access (argv[arg_pos], R_OK) == -1) + { + fprintf(stderr, "%s: Unable to access the patterndb file\n", argv[arg_pos]); + failed_to_validate = TRUE; + continue; + } + if (test_validate) { gchar cmd[1024]; -- 1.7.7.1
On Mon, 2011-10-31 at 18:16 +0100, Gergely Nagy wrote:
When run in test mode (pdbtool test), check that a file exists, before trying to load it, and return a sensible error message in case it does not.
applied both of your patches to 3.3. Thanks Gergely. -- Bazsi
participants (2)
-
Balazs Scheidler
-
Gergely Nagy