On Mon, Jun 12, 2017 at 11:38 PM, Vadim Kochan <vadi...@gmail.com> wrote:

> Trim output name to IFNAMSIZ only if the output is a networking device,
> otherwise the following error occured if output name is greater then
> IFNAMSIZ:
>
>         ~/src/netsniff-ng$ trafgen -n 1 '{ udp() }' -o
> /tmp/xxxxxxxxxxxxxx.pcap
>         No networking device or pcap file: /tmp/xxxxxxxxxx
>         Failed to open output device
> ---
>  trafgen.c     | 2 +-
>  trafgen_dev.c | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/trafgen.c b/trafgen.c
> index 6ae0076..b40d362 100644
> --- a/trafgen.c
> +++ b/trafgen.c
> @@ -1084,7 +1084,7 @@ int main(int argc, char **argv)
>                         break;
>                 case 'd':
>                 case 'o':
> -                       ctx.device = xstrndup(optarg, IFNAMSIZ);
> +                       ctx.device = xstrdup(optarg);
>                         break;
>                 case 'H':
>                         prio_high = true;
> diff --git a/trafgen_dev.c b/trafgen_dev.c
> index cd99a0c..bbe1be8 100644
> --- a/trafgen_dev.c
> +++ b/trafgen_dev.c
> @@ -174,8 +174,10 @@ struct dev_io *dev_io_open(const char *name, enum
> dev_io_mode_t mode)
>         struct dev_io *dev = xzmalloc(sizeof(struct dev_io));
>
>         if (strstr(name, ".pcap")) {
> +               dev->name = xstrdup(name);
>                 dev->ops = &dev_pcap_ops;
>         } else if (device_mtu(name) > 0) {
> +               dev->name = xstrndup(optarg, IFNAMSIZ);
>
>>>>> Ooooopsssss, sorry ... too late for fixing ...


>                 dev->ops = &dev_net_ops;
>         } else {
>                 fprintf(stderr, "No networking device or pcap file: %s\n",
> name);
> @@ -189,7 +191,6 @@ struct dev_io *dev_io_open(const char *name, enum
> dev_io_mode_t mode)
>                 }
>         }
>
> -       dev->name = xstrdup(name);
>         return dev;
>  };
>
> --
> 2.9.3
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to