Skip to content

Commit 250ef97

Browse files
committed
Make sure Format in structures is space-padded (see MQ APAR IT13736). Mentioned in #106
1 parent a7d48c8 commit 250ef97

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

ibmmq/mqi.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ func (e *MQReturn) Error() string {
122122
}
123123

124124
var endian binary.ByteOrder // Used by structure formatters such as MQCFH
125+
const space8 = " "
125126

126127
/*
127128
* Copy a Go string in "strings"

ibmmq/mqiDLH.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ func (dlh *MQDLH) Bytes() []byte {
100100
offset += 4
101101
endian.PutUint32(buf[offset:], uint32(dlh.CodedCharSetId))
102102
offset += 4
103-
copy(buf[offset:], dlh.Format)
103+
// Make sure the format is space padded to the correct length
104+
copy(buf[offset:], (dlh.Format + space8)[0:8])
104105
offset += int(MQ_FORMAT_LENGTH)
105106
endian.PutUint32(buf[offset:], uint32(dlh.PutApplType))
106107
offset += 4

ibmmq/mqiMQMD.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func NewMQMD() *MQMD {
7878
md.Feedback = int32(C.MQFB_NONE)
7979
md.Encoding = int32(C.MQENC_NATIVE)
8080
md.CodedCharSetId = int32(C.MQCCSI_Q_MGR)
81-
md.Format = " "
81+
md.Format = space8
8282
md.Priority = int32(C.MQPRI_PRIORITY_AS_Q_DEF)
8383
md.Persistence = int32(C.MQPER_PERSISTENCE_AS_Q_DEF)
8484
md.MsgId = bytes.Repeat([]byte{0}, C.MQ_MSG_ID_LENGTH)
@@ -113,7 +113,8 @@ func copyMDtoC(mqmd *C.MQMD, gomd *MQMD) {
113113
mqmd.Feedback = C.MQLONG(gomd.Feedback)
114114
mqmd.Encoding = C.MQLONG(gomd.Encoding)
115115
mqmd.CodedCharSetId = C.MQLONG(gomd.CodedCharSetId)
116-
setMQIString((*C.char)(&mqmd.Format[0]), gomd.Format, C.MQ_FORMAT_LENGTH)
116+
// Make sure Format is space padded
117+
setMQIString((*C.char)(&mqmd.Format[0]), (gomd.Format + space8), C.MQ_FORMAT_LENGTH)
117118
mqmd.Priority = C.MQLONG(gomd.Priority)
118119
mqmd.Persistence = C.MQLONG(gomd.Persistence)
119120

0 commit comments

Comments
 (0)