[prev in list] [next in list] [prev in thread] [next in thread]
List: asterisk-dev
Subject: Re: [asterisk-dev] [Code Review] fix odd logic in get_msg_text()
From: "mjordan" <reviewboard () asterisk ! org>
Date: 2011-11-23 19:48:19
Message-ID: 20111123194819.10641.61739 () hotblack ! digium ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1586/#review4860
-----------------------------------------------------------
Ship it!
And if you'd like, file an ASTERISK issue for the things that should be fix=
ed that are beyond the scope of this. It should at least be put in the que=
ue for things to improve on.
- mjordan
On Nov. 13, 2011, 9:02 a.m., wdoekes wrote:
> =
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1586/
> -----------------------------------------------------------
> =
> (Updated Nov. 13, 2011, 9:02 a.m.)
> =
> =
> Review request for Asterisk Developers and Olle E Johansson.
> =
> =
> Summary
> -------
> =
> The chan_sip get_msg_text was a bit of a mess:
> - it contained strlen(buf) where buf was always terminated on 0
> - it reserved 5 bytes for the buffer for who knows what
> - it decremented the allowed size by more than needed if addnewline was o=
ff
> - the addnewline parameter was a misnomer -- and imho the wrong fix to a =
problem
> - the \brief docs referred to a SIP MESSAGE, but it was used to get any s=
ip request body
> =
> I did the following:
> - I fixed the doxygen docs
> - looked over the numbers in get_msg_text() so buf is always filled to th=
e brim if too small
> - removed the addnewline parameter that Olle added in r116240
> - instead, I stripped all trailing newlines in the function that needed it
> =
> I believe r116240 was the wrong fix for the problem of trailing newlines:=
if the content is text/plain, newlines should certainly be allowed. Unless=
they're somehow used for folding the text/plain body -- which I haven't fo=
und any docs about -- removing them could cause linefeed separated text to =
be incorrectly joined.
> =
> (This is not an important issue at all.. but this review is here to clean=
up the patch in r1533.)
> =
> =
> This addresses bug ASTERISK-18389.
> https://issues.asterisk.org/jira/browse/ASTERISK-18389
> =
> =
> Diffs
> -----
> =
> /branches/1.8/channels/chan_sip.c 345022 =
> =
> Diff: https://reviewboard.asterisk.org/r/1586/diff
> =
> =
> Testing
> -------
> =
> It compiles.
> =
> =
> Thanks,
> =
> wdoekes
> =
>
[Attachment #5 (text/html)]
<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;"> <tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/1586/">https://reviewboard.asterisk.org/r/1586/</a>
</td>
</tr>
</table>
<br />
<p>Ship it!</p>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">And if you'd like, \
file an ASTERISK issue for the things that should be fixed that are beyond the scope \
of this. It should at least be put in the queue for things to improve on.</pre> <br \
/>
<p>- mjordan</p>
<br />
<p>On November 13th, 2011, 9:02 a.m., wdoekes wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('https://reviewboard.asterisk.org/media/rb/images/review_request_box_top_bg.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;"> <tr>
<td>
<div>Review request for Asterisk Developers and Olle E Johansson.</div>
<div>By wdoekes.</div>
<p style="color: grey;"><i>Updated Nov. 13, 2011, 9:02 a.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">The chan_sip get_msg_text was a bit of a mess:
- it contained strlen(buf) where buf was always terminated on 0
- it reserved 5 bytes for the buffer for who knows what
- it decremented the allowed size by more than needed if addnewline was off
- the addnewline parameter was a misnomer -- and imho the wrong fix to a problem
- the \brief docs referred to a SIP MESSAGE, but it was used to get any sip request \
body
I did the following:
- I fixed the doxygen docs
- looked over the numbers in get_msg_text() so buf is always filled to the brim if \
too small
- removed the addnewline parameter that Olle added in r116240
- instead, I stripped all trailing newlines in the function that needed it
I believe r116240 was the wrong fix for the problem of trailing newlines: if the \
content is text/plain, newlines should certainly be allowed. Unless they're \
somehow used for folding the text/plain body -- which I haven't found any docs \
about -- removing them could cause linefeed separated text to be incorrectly joined.
(This is not an important issue at all.. but this review is here to clean up the \
patch in r1533.)</pre> </td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">It compiles.</pre> </td>
</tr>
</table>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-18389">ASTERISK-18389</a>
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/branches/1.8/channels/chan_sip.c <span style="color: grey">(345022)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/1586/diff/" style="margin-left: \
3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic