On Sun, May 28, 2017 at 10:12:24AM +0200, Michal Mazurek wrote:
> Reduce differences between the two pfctl_osfp.c files.
>
> Apply three commits from pfctl/pfctl_osfp.c, this time with binary change.
>
> Make sure that fingerprint_count gets reset to 0 correctly when we
> flush our list of fingerprints.
>
> second:
>
> Plug simple memory leak. ``Don't forget to free tcpopts when you
> are done.''
>
> third:
>
> print_ioctl() is unused if not debugging. Found with clang, after
> marking the function "static". Use OSFP_DEBUG, in a similar
> fashion to OPT_DEBUG (pfctl_optimize.c).
>
> OK?
OK bluhm@
>
> Index: usr.sbin/tcpdump/pfctl_osfp.c
> ===
> RCS file: /cvs/src/usr.sbin/tcpdump/pfctl_osfp.c,v
> retrieving revision 1.12
> diff -u -p -r1.12 pfctl_osfp.c
> --- usr.sbin/tcpdump/pfctl_osfp.c 28 May 2017 07:40:12 - 1.12
> +++ usr.sbin/tcpdump/pfctl_osfp.c 28 May 2017 08:07:36 -
> @@ -38,7 +38,8 @@
>
> #define MAXIMUM(a, b)(((a) > (b)) ? (a) : (b))
>
> -#if 0
> +/* #define OSFP_DEBUG1 */
> +#ifdef OSFP_DEBUG
> # define DEBUG(fp, str, v...) \
> fprintf(stderr, "%s:%s:%s " str "\n", (fp)->fp_os.fp_class_nm, \
> (fp)->fp_os.fp_version_nm, (fp)->fp_os.fp_subtype_nm , ## v);
> @@ -73,7 +74,9 @@ int get_tcpopts(const char *, int, co
> pf_tcpopts_t *, int *, int *, int *, int *, int *,
> int *);
> void import_fingerprint(struct pf_osfp_ioctl *);
> +#ifdef OSFP_DEBUG
> const char *print_ioctl(struct pf_osfp_ioctl *);
> +#endif
> void print_name_list(int, struct name_list *, const char *);
> void sort_name_list(int, struct name_list *);
> struct name_entry*lookup_name_list(struct name_list *, const char *);
> @@ -243,6 +246,7 @@ pfctl_file_fingerprints(int dev, int opt
> free(version);
> free(subtype);
> free(desc);
> + free(tcpopts);
>
> if (opts & PF_OPT_VERBOSE2)
> printf("Loaded %d passive OS fingerprints\n",
> @@ -267,9 +271,9 @@ pfctl_flush_my_fingerprints(struct name_
> while ((nm = LIST_FIRST(list)) != NULL) {
> LIST_REMOVE(nm, nm_entry);
> pfctl_flush_my_fingerprints(&nm->nm_sublist);
> - fingerprint_count--;
> free(nm);
> }
> + fingerprint_count = 0;
> class_count = 0;
> }
>
> @@ -980,6 +984,7 @@ get_field(u_char **line, size_t *len, in
> }
>
>
> +#ifdef OSFP_DEBUG
> const char *
> print_ioctl(struct pf_osfp_ioctl *fp)
> {
> @@ -1081,3 +1086,4 @@ print_ioctl(struct pf_osfp_ioctl *fp)
>
> return (buf);
> }
> +#endif
>
> --
> Michal Mazurek