From: Denis Kenzior <denkenz@gmail.com>
To: ell@lists.01.org
Subject: Re: [PATCH 02/12] dbus: Validate field type in get_header_field
Date: Mon, 11 Apr 2016 15:00:40 -0500 [thread overview]
Message-ID: <570C0268.3020301@gmail.com> (raw)
In-Reply-To: <1460260961-9183-2-git-send-email-andrew.zaborowski@intel.com>
[-- Attachment #1: Type: text/plain, Size: 5961 bytes --]
Hi Andrew,
On 04/09/2016 11:02 PM, Andrew Zaborowski wrote:
> It seems there's no place where we are validating the header
> fields of incoming messages so let's do it here.
> ---
> ell/dbus-message.c | 35 ++++++++++++++++++++---------------
> 1 file changed, 20 insertions(+), 15 deletions(-)
>
> diff --git a/ell/dbus-message.c b/ell/dbus-message.c
> index ece98a4..6e2831b 100644
> --- a/ell/dbus-message.c
> +++ b/ell/dbus-message.c
> @@ -554,7 +554,8 @@ static inline bool message_iter_next_entry(struct l_dbus_message_iter *iter,
> }
>
> static bool get_header_field_from_iter_valist(struct l_dbus_message *message,
> - uint8_t type, va_list args)
> + uint8_t type, char data_type,
> + va_list args)
> {
> struct l_dbus_message_iter header;
> struct l_dbus_message_iter array, iter;
> @@ -591,6 +592,9 @@ static bool get_header_field_from_iter_valist(struct l_dbus_message *message,
> if (field_type != type)
> continue;
>
> + if (iter.sig_start[iter->sig_pos] != data_type)
> + return false;
> +
CC ell/dbus-message.lo
ell/dbus-message.c: In function ‘get_header_field_from_iter_valist’:
ell/dbus-message.c:595:26: error: invalid type argument of ‘->’ (have
‘struct l_dbus_message_iter’)
if (iter.sig_start[iter->sig_pos] != data_type)
^
Should that be iter.sig_pos?
> return message_iter_next_entry_valist(&iter, args);
> }
>
> @@ -598,13 +602,14 @@ static bool get_header_field_from_iter_valist(struct l_dbus_message *message,
> }
>
> static inline bool get_header_field(struct l_dbus_message *message,
> - uint8_t type, ...)
> + uint8_t type, char data_type, ...)
> {
> va_list args;
> bool result;
>
> - va_start(args, type);
> - result = get_header_field_from_iter_valist(message, type, args);
> + va_start(args, data_type);
> + result = get_header_field_from_iter_valist(message, type, data_type,
> + args);
> va_end(args);
>
> return result;
> @@ -658,7 +663,7 @@ struct l_dbus_message *dbus_message_from_blob(const void *data, size_t size)
>
> message->sealed = true;
>
> - get_header_field(message, DBUS_MESSAGE_FIELD_SIGNATURE,
> + get_header_field(message, DBUS_MESSAGE_FIELD_SIGNATURE, 'g',
> &message->signature);
>
> return message;
> @@ -690,7 +695,7 @@ struct l_dbus_message *dbus_message_build(void *header, size_t header_size,
>
> message->sealed = true;
>
> - get_header_field(message, DBUS_MESSAGE_FIELD_SIGNATURE,
> + get_header_field(message, DBUS_MESSAGE_FIELD_SIGNATURE, 'g',
> &message->signature);
>
> return message;
> @@ -1095,7 +1100,7 @@ static bool append_arguments(struct l_dbus_message *message,
> build_header(message, signature);
> message->sealed = true;
>
> - get_header_field(message, DBUS_MESSAGE_FIELD_SIGNATURE,
> + get_header_field(message, DBUS_MESSAGE_FIELD_SIGNATURE, 'g',
> &message->signature);
>
> return true;
> @@ -1130,7 +1135,7 @@ LIB_EXPORT bool l_dbus_message_get_error(struct l_dbus_message *message,
> return false;
>
> if (!message->error_name)
> - get_header_field(message, DBUS_MESSAGE_FIELD_ERROR_NAME,
> + get_header_field(message, DBUS_MESSAGE_FIELD_ERROR_NAME, 's',
> &message->error_name);
>
> if (name)
> @@ -1213,7 +1218,7 @@ LIB_EXPORT const char *l_dbus_message_get_path(struct l_dbus_message *message)
> return NULL;
>
> if (!message->path)
> - get_header_field(message, DBUS_MESSAGE_FIELD_PATH,
> + get_header_field(message, DBUS_MESSAGE_FIELD_PATH, 'o',
> &message->path);
>
> return message->path;
> @@ -1225,7 +1230,7 @@ LIB_EXPORT const char *l_dbus_message_get_interface(struct l_dbus_message *messa
> return NULL;
>
> if (!message->interface)
> - get_header_field(message, DBUS_MESSAGE_FIELD_INTERFACE,
> + get_header_field(message, DBUS_MESSAGE_FIELD_INTERFACE, 's',
> &message->interface);
>
> return message->interface;
> @@ -1237,7 +1242,7 @@ LIB_EXPORT const char *l_dbus_message_get_member(struct l_dbus_message *message)
> return NULL;
>
> if (!message->member)
> - get_header_field(message, DBUS_MESSAGE_FIELD_MEMBER,
> + get_header_field(message, DBUS_MESSAGE_FIELD_MEMBER, 's',
> &message->member);
>
> return message->member;
> @@ -1249,7 +1254,7 @@ LIB_EXPORT const char *l_dbus_message_get_destination(struct l_dbus_message *mes
> return NULL;
>
> if (!message->destination)
> - get_header_field(message, DBUS_MESSAGE_FIELD_DESTINATION,
> + get_header_field(message, DBUS_MESSAGE_FIELD_DESTINATION, 's',
> &message->destination);
>
> return message->destination;
> @@ -1261,7 +1266,7 @@ LIB_EXPORT const char *l_dbus_message_get_sender(struct l_dbus_message *message)
> return NULL;
>
> if (!message->sender)
> - get_header_field(message, DBUS_MESSAGE_FIELD_SENDER,
> + get_header_field(message, DBUS_MESSAGE_FIELD_SENDER, 's',
> &message->sender);
>
> return message->sender;
> @@ -1282,7 +1287,7 @@ uint32_t _dbus_message_get_reply_serial(struct l_dbus_message *message)
> return 0;
>
> if (message->reply_serial == 0)
> - get_header_field(message, DBUS_MESSAGE_FIELD_REPLY_SERIAL,
> + get_header_field(message, DBUS_MESSAGE_FIELD_REPLY_SERIAL, 'u',
> &message->reply_serial);
>
> return message->reply_serial;
> @@ -1809,7 +1814,7 @@ LIB_EXPORT struct l_dbus_message *l_dbus_message_builder_finalize(
> build_header(builder->message, generated_signature);
> builder->message->sealed = true;
>
> - get_header_field(builder->message, DBUS_MESSAGE_FIELD_SIGNATURE,
> + get_header_field(builder->message, DBUS_MESSAGE_FIELD_SIGNATURE, 'g',
> &builder->message->signature);
> l_free(generated_signature);
>
>
Regards,
-Denis
next prev parent reply other threads:[~2016-04-11 20:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-10 4:02 [PATCH 01/12] dbus: Kdbus message timeout_ns is absolute time Andrew Zaborowski
2016-04-10 4:02 ` [PATCH 02/12] dbus: Validate field type in get_header_field Andrew Zaborowski
2016-04-11 20:00 ` Denis Kenzior [this message]
2016-04-11 20:06 ` Andrzej Zaborowski
2016-04-10 4:02 ` [PATCH 03/12] dbus: Check some more return values when parsing messages Andrew Zaborowski
2016-04-11 20:11 ` Denis Kenzior
2016-04-12 1:23 ` Andrzej Zaborowski
2016-04-10 4:02 ` [PATCH 04/12] dbus: GVariant header field identifiers are 64-bit Andrew Zaborowski
2016-04-10 4:02 ` [PATCH 05/12] dbus: Fix parsing GVariant header/body information Andrew Zaborowski
2016-04-10 4:02 ` [PATCH 06/12] dbus: GVariant message cookie and reply cookie are 64-bit Andrew Zaborowski
2016-04-10 4:02 ` [PATCH 07/12] dbus: Don't rely on 1st KDBUS_ITEM_PAYLOAD_OFF being the header Andrew Zaborowski
2016-04-10 4:02 ` [PATCH 08/12] gvariant: Utility to build GVariant message out of header+body Andrew Zaborowski
2016-04-10 4:02 ` [PATCH 09/12] dbus: Fix the kdbus message encoding Andrew Zaborowski
2016-04-11 19:42 ` [PATCH 01/12] dbus: Kdbus message timeout_ns is absolute time Denis Kenzior
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=570C0268.3020301@gmail.com \
--to=denkenz@gmail.com \
--cc=ell@lists.01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.