From: Johan Hedberg <johan.hedberg@gmail.com>
To: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCHv2 10/10] obexd: Fix possible NULL dereference
Date: Mon, 11 Aug 2014 16:37:20 +0300 [thread overview]
Message-ID: <20140811133720.GB28382@t440s> (raw)
In-Reply-To: <1407743445-1329-10-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Mon, Aug 11, 2014, Andrei Emeltchenko wrote:
> In a case snprintf fails we have NULL dereference. Fixes clang warnings
> below:
> ...
> obexd/client/map.c:471:9: warning: Access to field 'message' results in
> a dereference of a null pointer (loaded from variable 'err')
> err->message);
> ^~~~~~~~~~~~
> obexd/client/map.c:772:9: warning: Access to field 'message' results in
> a dereference of a null pointer (loaded from variable 'err')
> err->message);
> ^~~~~~~~~~~~
> ...
> ---
> obexd/client/map.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
I've applied patches 3-9 (1 & 2 already had feedback). This one needs a
bit more consideration too:
> diff --git a/obexd/client/map.c b/obexd/client/map.c
> index 47afc31..ed535e2 100644
> --- a/obexd/client/map.c
> +++ b/obexd/client/map.c
> @@ -468,7 +468,7 @@ static DBusMessage *map_msg_get(DBusConnection *connection,
>
> fail:
> reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s",
> - err->message);
> + err ? err->message : "");
> g_error_free(err);
> return reply;
> }
> @@ -769,7 +769,7 @@ static void set_status(const GDBusPropertyTable *property,
>
> fail:
> g_dbus_pending_property_error(id, ERROR_INTERFACE ".Failed", "%s",
> - err->message);
> + err ? err->message : "");
> g_error_free(err);
> }
It seems to me that the only code path that can lead to err being still
NULL is this one:
if (snprintf(handle, sizeof(handle), "%" PRIx64, msg->handle) < 0)
goto fail;
All others should have err != NULL. I don't really see how snprintf
could ever fail in this case, so probably the simplest solution would be
to just remove the error check there?
Johan
next prev parent reply other threads:[~2014-08-11 13:37 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-11 7:50 [PATCHv2 01/10] monitor: Fix segmentation fault with malformed packet Andrei Emeltchenko
2014-08-11 7:50 ` [PATCHv2 02/10] monitor: Handle default switch case Andrei Emeltchenko
2014-08-11 13:25 ` Johan Hedberg
2014-08-11 7:50 ` [PATCHv2 03/10] emulator: Fix resource leak closing fd Andrei Emeltchenko
2014-08-11 7:50 ` [PATCHv2 04/10] tools: Fix resource leak closing sk Andrei Emeltchenko
2014-08-11 7:50 ` [PATCHv2 05/10] gobex: Fix use after free Andrei Emeltchenko
2014-08-11 7:50 ` [PATCHv2 06/10] " Andrei Emeltchenko
2014-08-11 7:50 ` [PATCHv2 07/10] " Andrei Emeltchenko
2014-08-11 7:50 ` [PATCHv2 08/10] proximity: " Andrei Emeltchenko
2014-08-11 7:50 ` [PATCHv2 09/10] gdbus: " Andrei Emeltchenko
2014-08-11 7:50 ` [PATCHv2 10/10] obexd: Fix possible NULL dereference Andrei Emeltchenko
2014-08-11 13:37 ` Johan Hedberg [this message]
2014-08-12 7:57 ` Andrei Emeltchenko
2014-08-11 13:22 ` [PATCHv2 01/10] monitor: Fix segmentation fault with malformed packet Johan Hedberg
2014-08-12 7:55 ` Andrei Emeltchenko
2014-08-12 9:04 ` Johan Hedberg
2014-08-12 12:46 ` [PATCHv3 1/5] monitor: Use common maximum packet size definition Andrei Emeltchenko
2014-08-12 12:46 ` [PATCHv3 2/5] shared/btsnoop: Fix segmentation fault with malformed packet Andrei Emeltchenko
2014-08-12 12:46 ` [PATCHv3 3/5] btmon: " Andrei Emeltchenko
2014-08-12 12:46 ` [PATCHv3 4/5] monitor: Handle default switch case Andrei Emeltchenko
2014-08-13 9:19 ` Johan Hedberg
2014-08-13 11:32 ` [PATCHv4] " Andrei Emeltchenko
2014-08-13 11:42 ` Johan Hedberg
2014-08-12 12:46 ` [PATCHv3 5/5] obexd: Fix possible NULL dereference Andrei Emeltchenko
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140811133720.GB28382@t440s \
--to=johan.hedberg@gmail.com \
--cc=Andrei.Emeltchenko.news@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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).