Merge lp:~sergiusens/nuntium/length_limits into lp:nuntium

Proposed by Sergio Schvezov
Status: Merged
Approved by: Manuel de la Peña
Approved revision: 70
Merged at revision: 52
Proposed branch: lp:~sergiusens/nuntium/length_limits
Merge into: lp:nuntium
Prerequisite: lp:~sergiusens/nuntium/smil_fix
Diff against target: 50 lines (+6/-6)
3 files modified
mms/decoder.go (+1/-1)
mms/encode_decode_test.go (+4/-4)
mms/encoder.go (+1/-1)
To merge this branch: bzr merge lp:~sergiusens/nuntium/length_limits
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve
Review via email: mp+225272@code.launchpad.net

Commit message

Length bound checks fix

To post a comment you must log in.
lp:~sergiusens/nuntium/length_limits updated
70. By Sergio Schvezov

Fixing bound check on short length max

71. By Sergio Schvezov

Merged smil_fix into length_limits.

72. By Sergio Schvezov

Merged smil_fix into length_limits.

73. By Sergio Schvezov

Merged smil_fix into length_limits.

74. By Sergio Schvezov

Merged smil_fix into length_limits.

Revision history for this message
Manuel de la Peña (mandel) :
review: Approve
lp:~sergiusens/nuntium/length_limits updated
75. By Sergio Schvezov

Merged smil_fix into length_limits.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mms/decoder.go'
2--- mms/decoder.go 2014-07-02 21:07:32 +0000
3+++ mms/decoder.go 2014-07-02 21:07:32 +0000
4@@ -90,7 +90,7 @@
5 // Length = Uintvar-integer
6 func (dec *MMSDecoder) ReadLength(reflectedPdu *reflect.Value) (length uint64, err error) {
7 switch {
8- case dec.Data[dec.Offset+1]&0x7f < SHORT_LENGTH_MAX:
9+ case dec.Data[dec.Offset+1]&0x7f <= SHORT_LENGTH_MAX:
10 l, err := dec.ReadShortInteger(nil, "")
11 v := uint64(l)
12 if reflectedPdu != nil {
13
14=== modified file 'mms/encode_decode_test.go'
15--- mms/encode_decode_test.go 2014-07-02 21:07:32 +0000
16+++ mms/encode_decode_test.go 2014-07-02 21:07:32 +0000
17@@ -95,8 +95,8 @@
18 }
19
20 func (s *EncodeDecodeTestSuite) TestLength(c *C) {
21- // >= 30 requires encoding with length quote
22- testLengths := []uint64{10, 1, 29, 30, 500}
23+ // > 30 requires encoding with length quote
24+ testLengths := []uint64{10, 1, 29, 30, 31, 500}
25 for i := range testLengths {
26 c.Assert(s.enc.writeLength(testLengths[i]), IsNil)
27 }
28@@ -104,7 +104,7 @@
29 s.dec = NewDecoder(bytes)
30 for i := range testLengths {
31 integer, err := s.dec.ReadLength(nil)
32- c.Assert(err, IsNil, Commentf("%d != %d with encoded bytes starting at %d: %d", integer, testLengths[i], i, bytes))
33- c.Check(integer, Equals, testLengths[i], Commentf("%d != %d with encoded bytes starting at %d: %d", integer, testLengths[i], i, bytes))
34+ c.Assert(err, IsNil, Commentf("%d != %d with encoded bytes starting at %d: %d", integer, testLengths[i], s.dec.Offset, bytes))
35+ c.Check(integer, Equals, testLengths[i], Commentf("%d != %d with encoded bytes starting at %d: %d", integer, testLengths[i], s.dec.Offset, bytes))
36 }
37 }
38
39=== modified file 'mms/encoder.go'
40--- mms/encoder.go 2014-07-02 21:07:32 +0000
41+++ mms/encoder.go 2014-07-02 21:07:32 +0000
42@@ -182,7 +182,7 @@
43 }
44
45 func (enc *MMSEncoder) writeLength(length uint64) error {
46- if length < SHORT_LENGTH_MAX {
47+ if length <= SHORT_LENGTH_MAX {
48 return enc.writeShortInteger(length)
49 } else {
50 if err := enc.writeByte(LENGTH_QUOTE); err != nil {

Subscribers

People subscribed via source and target branches