Fixes to chkprintcap:
- Check the return from a call to malloc() in skim_printcap(), and return a NULL if that fails. - Fix a small memory leak in main() that happens if skim_printcap() returns an error, including the new error-return of NULL. Submitted by: Tom Rix <trix@juniper.net> Reviewed by: pfg, ngie MFC after: 4 weeks Sponsored by: Dell EMC Isilon, Juniper Differential Revision: D9954, D9982
This commit is contained in:
parent
f3e05661e1
commit
e550d65c85
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=315655
@ -113,8 +113,13 @@ main(int argc, char **argv)
|
|||||||
* the printcap file.
|
* the printcap file.
|
||||||
*/
|
*/
|
||||||
skres = skim_printcap(pcap_fname, verbosity);
|
skres = skim_printcap(pcap_fname, verbosity);
|
||||||
if (skres->fatalerr)
|
if (skres == NULL) {
|
||||||
return (skres->fatalerr);
|
problems = 1;
|
||||||
|
goto main_ret;
|
||||||
|
} else if (skres->fatalerr) {
|
||||||
|
problems = skres->fatalerr;
|
||||||
|
goto main_ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now use the standard capability-db routines to check the values
|
* Now use the standard capability-db routines to check the values
|
||||||
@ -156,6 +161,9 @@ main(int argc, char **argv)
|
|||||||
warnx("WARNING: but only found %d queues to process!",
|
warnx("WARNING: but only found %d queues to process!",
|
||||||
queuecnt);
|
queuecnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main_ret:
|
||||||
|
free(pcap_fname);
|
||||||
return (problems);
|
return (problems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +82,8 @@ skim_printcap(const char *pcap_fname, int verbosity)
|
|||||||
enum {CMNT_LINE, ENTRY_LINE, TAB_LINE, TABERR_LINE} is_type, had_type;
|
enum {CMNT_LINE, ENTRY_LINE, TAB_LINE, TABERR_LINE} is_type, had_type;
|
||||||
|
|
||||||
skinf = malloc(sizeof(struct skiminfo));
|
skinf = malloc(sizeof(struct skiminfo));
|
||||||
|
if (skinf == NULL)
|
||||||
|
return (NULL);
|
||||||
memset(skinf, 0, sizeof(struct skiminfo));
|
memset(skinf, 0, sizeof(struct skiminfo));
|
||||||
|
|
||||||
pc_file = fopen(pcap_fname, "r");
|
pc_file = fopen(pcap_fname, "r");
|
||||||
|
Loading…
Reference in New Issue
Block a user