wireguard.lists.zx2c4.com archive mirror
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: "Lukas Lüdke" <lukasluedke@web.de>
Cc: WireGuard mailing list <wireguard@lists.zx2c4.com>
Subject: Re: Problem using "WireGuardSetConfiguration" for Wireguard-NT with heap allocated configuration
Date: Sat, 14 Aug 2021 00:19:55 +0200	[thread overview]
Message-ID: <CAHmME9pPK5v24XHUe8z8Ddc5a3hsamg_xKwdKJLgjPpoTVVi7A@mail.gmail.com> (raw)
In-Reply-To: <e3f36b3e-5337-0d04-6c8a-9ce1bb6c234e@web.de>

Hi Lukas,

This appears to be a C pointer snafu, with this line in the code you sent:

> if (!WireGuardSetConfiguration(Adapter, (WIREGUARD_INTERFACE*)&(buffer), sizeof(struct t))) {

The issue is that `buffer` is already a pointer to the malloc'd
memory, so passing &buffer is actually the address of the pointer that
points to the memory you want. The reason why the example.c code
passes "&thing" and not "thing" is because thing is on the stack. But
in your case, `buffer` is on the heap, so it's already a pointer. The
second thing that stands out is `sizeof(struct t)` might not be what
you want. Instead try providing as length the same length that you
passed to the malloc call -- sizeof(iface)+sizeof(peer).

Hope that helps.


      reply	other threads:[~2021-08-13 22:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 22:02 Problem using "WireGuardSetConfiguration" for Wireguard-NT with heap allocated configuration Lukas Lüdke
2021-08-13 22:19 ` Jason A. Donenfeld [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHmME9pPK5v24XHUe8z8Ddc5a3hsamg_xKwdKJLgjPpoTVVi7A@mail.gmail.com \
    --to=jason@zx2c4.com \
    --cc=lukasluedke@web.de \
    --cc=wireguard@lists.zx2c4.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).