Skip to content

Commit 4a388b2

Browse files
hujiaming.0927hujm2023
hujiaming.0927
authored andcommitted
fix: decode error for short_message
1 parent 4f2b06c commit 4a388b2

File tree

5 files changed

+5
-9
lines changed

5 files changed

+5
-9
lines changed

cmpp/cmpp20/pdu_submit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func (p *PduSubmit) IDecode(data []byte) error {
153153
p.DestTerminalID[i] = b.ReadCStringN(21)
154154
}
155155
p.MsgLength = b.ReadUint8()
156-
p.MsgContent = b.ReadCStringN(int(p.MsgLength))
156+
p.MsgContent = string(b.ReadNBytes(int(p.MsgLength)))
157157
p.Reserve = b.ReadCStringN(8)
158158

159159
return b.Error()

smgp/smgp30/pdu_deliver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (d *Deliver) IDecode(data []byte) error {
7070
d.SrcTermID = b.ReadCStringN(21)
7171
d.DestTermID = b.ReadCStringN(21)
7272
d.MsgLength = b.ReadUint8()
73-
d.MsgContent = b.ReadCStringNWithoutTrim(int(d.MsgLength))
73+
d.MsgContent = string(b.ReadNBytes(int(d.MsgLength)))
7474
d.Reserve = b.ReadCStringN(8)
7575
d.Options = smgp.ReadOptions(b)
7676

smgp/smgp30/pdu_submit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (s *Submit) IDecode(data []byte) error {
103103
s.DestTermID = append(s.DestTermID, tmp)
104104
}
105105
s.MsgLength = b.ReadUint8()
106-
s.MsgContent = b.ReadCStringN(int(s.MsgLength))
106+
s.MsgContent = string(b.ReadNBytes(int(s.MsgLength)))
107107
s.Reserve = b.ReadCStringN(8)
108108

109109
var parseErr error

smpp/smpp34/pdu_deliver_sm.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ func (d *DeliverSm) IDecode(data []byte) error {
6868
d.DataCoding = buf.ReadUint8()
6969
d.SmDefaultMsgId = buf.ReadUint8()
7070
d.SmLength = buf.ReadUint8()
71-
temp := make([]byte, d.SmLength)
72-
buf.ReadBytes(temp)
73-
d.ShortMessage = temp
71+
d.ShortMessage = buf.ReadNBytes(int(d.SmLength))
7472
d.TLVs = smpp.ReadTLVs1(buf)
7573

7674
return buf.Error()

smpp/smpp34/pdu_submit_sm.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ func (s *SubmitSm) IDecode(data []byte) error {
7070
s.DataCoding = r.ReadUint8()
7171
s.SmDefaultMsgID = r.ReadUint8()
7272
s.SmLength = r.ReadUint8()
73-
temp := make([]byte, s.SmLength)
74-
r.ReadBytes(temp)
75-
s.ShortMessage = temp
73+
s.ShortMessage = r.ReadNBytes(int(s.SmLength))
7674
s.TLVs = smpp.ReadTLVs1(r)
7775

7876
return r.Error()

0 commit comments

Comments
 (0)