[Swan] redundant code in ikev1.c

Paul Wouters paul at nohats.ca
Fri Mar 1 07:30:06 EET 2013


On Fri, 1 Mar 2013, D. Hugh Redelmeier wrote:

> disp_buf and disp_len are pointless.  Some work is done to fill them in,
> but the result is never used.
>
> (If add code to use the results, I would recommend that their scopes be
> shrunk.)

It does look sketchy:

             if (pbs_left(n_pbs) >= sizeof(disp_buf)-1)
                 disp_len = sizeof(disp_buf)-1;
             else
                 disp_len = pbs_left(n_pbs);
             memcpy(disp_buf, n_pbs->cur, disp_len);
             disp_buf[disp_len] = '\0';

             loglog(RC_LOG_SERIOUS, "received and ignored informational message");

It is used to set the maximum size of the informational message?
It copies at most 200 characters? But then it is not actually using it
in the log line.

The code moved from demux.c to ikev1.c to support ikev2, but it had the
same problem in the original code (git commit 67548e95)

Paul


More information about the Swan mailing list