From: Bart Westgeest <bart@elbrys.com>
To: Anderson Lizardo <anderson.lizardo@openbossa.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 3/3] sdp: Upgrade datatype SEQ8 to SEQ16 when data size is greater than 256
Date: Mon, 19 Nov 2012 16:33:10 -0500 [thread overview]
Message-ID: <50AAA596.3030509@elbrys.com> (raw)
In-Reply-To: <CAJdJm_N1hJkdEqvOrgD8ErAzDT56wzPEYAiA+7KDR0Pah4P6sA@mail.gmail.com>
Hi Anderson,
>> +recalculate:
>> + pdu_size = sdp_get_data_type_size(d->dtd);
>> buf->data_size += pdu_size;
>>
>> data_size = sdp_get_data_size(buf, d);
>> + if (data_size > UCHAR_MAX && d->dtd == SDP_SEQ8) {
>> + buf->data_size = orig_data_size;
>> + d->dtd = SDP_SEQ16;
>> + goto recalculate;
>
> IMHO, using "goto" here is too complicated for 3 lines of code that
> will just be run at most twice. So I would simply duplicate them
> inside the if(). But others may have different opinion on this regard.
I don't have strong feelings about this. I can change it.
One could argue that the way I did it shows that the *same* code needs
to be executed again. (It the same code can also be moved into a
do-while) - this, as well what I have currently, would allow for a data
upgrade to SDP_SEQ16 -> SDP_SEQ32, and SDP_ALT8 -> SDP_ALT16-> SDP_ALT32
as well, which theoretically are also needed as far as I can tell.
For the record, in any regard, I think the fix is rather ugly, goto
statement or not. This problem is now 'fixed' in two places (the other
one in sdp_append_to_buf, with the corresponding data length increase in
sdp_gen_buffer). IMHO, the code requires a bigger cleanup. I actually
made an attempt at it, but the fix got too big, and I opted for what I
submitted instead.
To get back on topic, let me know if you or others want me to re-submit.
Bart
next prev parent reply other threads:[~2012-11-19 21:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-19 19:04 [PATCH 0/3] Fix corrupted SDP response for sequence size > 256 Bart Westgeest
2012-11-19 19:04 ` [PATCH 1/3] sdp: Inlined single use of function sdp_set_data_type Bart Westgeest
2012-11-19 19:04 ` [PATCH 2/3] sdp: Limit side effects of sdp_get_data_type and sdp_get_data_size Bart Westgeest
2012-11-19 20:24 ` Anderson Lizardo
2012-11-19 21:06 ` Bart Westgeest
2012-11-19 19:04 ` [PATCH 3/3] sdp: Upgrade datatype SEQ8 to SEQ16 when data size is greater than 256 Bart Westgeest
2012-11-19 20:38 ` Anderson Lizardo
2012-11-19 21:33 ` Bart Westgeest [this message]
2012-11-20 12:57 ` [PATCH 0/3] Fix corrupted SDP response for sequence size > 256 Johan Hedberg
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=50AAA596.3030509@elbrys.com \
--to=bart@elbrys.com \
--cc=anderson.lizardo@openbossa.org \
--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 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.