From 602fa8323919fbe89ce9a311b0d1b3a6c8d0cfad Mon Sep 17 00:00:00 2001 From: Andriy Voskoboinyk Date: Wed, 30 Jan 2019 12:32:47 +0000 Subject: [PATCH] ndiscvt(8): abort if no IDs were found during conversion. Checked with Broadcom driver mentioned in PR 179285. PR: 69268 Submitted by: MFC after: 5 days --- usr.sbin/ndiscvt/inf.c | 26 ++++++++++++++------------ usr.sbin/ndiscvt/ndiscvt.c | 3 ++- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/usr.sbin/ndiscvt/inf.c b/usr.sbin/ndiscvt/inf.c index eb1015083dbb..442e7f61b1fd 100644 --- a/usr.sbin/ndiscvt/inf.c +++ b/usr.sbin/ndiscvt/inf.c @@ -62,9 +62,9 @@ static struct assign (struct assign *); static struct section *find_section (const char *); -static void dump_deviceids_pci (void); -static void dump_deviceids_pcmcia (void); -static void dump_deviceids_usb (void); +static int dump_deviceids_pci (void); +static int dump_deviceids_pcmcia (void); +static int dump_deviceids_usb (void); static void dump_pci_id (const char *); static void dump_pcmcia_id (const char *); static void dump_usb_id (const char *); @@ -85,9 +85,11 @@ inf_parse (FILE *fp, FILE *outfp) yyin = fp; yyparse(); - dump_deviceids_pci(); - dump_deviceids_pcmcia(); - dump_deviceids_usb(); + if (dump_deviceids_pci() == 0 && + dump_deviceids_pcmcia() == 0 && + dump_deviceids_usb() == 0) + return (-1); + fprintf(outfp, "#ifdef NDIS_REGVALS\n"); dump_regvals(); fprintf(outfp, "#endif /* NDIS_REGVALS */\n"); @@ -280,7 +282,7 @@ dump_usb_id(const char *s) fprintf(ofp, "\t\\\n\t{ %s, %s, ", vidstr, pidstr); } -static void +static int dump_deviceids_pci() { struct assign *manf, *dev; @@ -370,10 +372,10 @@ dump_deviceids_pci() fprintf(ofp, "\n\n"); - return; + return (found); } -static void +static int dump_deviceids_pcmcia() { struct assign *manf, *dev; @@ -463,10 +465,10 @@ dump_deviceids_pcmcia() fprintf(ofp, "\n\n"); - return; + return (found); } -static void +static int dump_deviceids_usb() { struct assign *manf, *dev; @@ -556,7 +558,7 @@ dump_deviceids_usb() fprintf(ofp, "\n\n"); - return; + return (found); } static void diff --git a/usr.sbin/ndiscvt/ndiscvt.c b/usr.sbin/ndiscvt/ndiscvt.c index 276a6ef7bfdd..1b7660700786 100644 --- a/usr.sbin/ndiscvt/ndiscvt.c +++ b/usr.sbin/ndiscvt/ndiscvt.c @@ -372,7 +372,8 @@ main(int argc, char *argv[]) err(1, "opening .INF file '%s' failed", inffile); - inf_parse(fp, outfp); + if (inf_parse(fp, outfp) != 0) + errx(1, "creating .INF file - no entries created, are you using the correct files?"); fclose(fp); }