@@ -872,7 +872,7 @@ func (dns *Msg) unpack(dh Header, msg []byte, off int) (err error) {
872
872
// TODO(miek) make this an error?
873
873
// use PackOpt to let people tell how detailed the error reporting should be?
874
874
// if off != len(msg) {
875
- // // println("dns: extra bytes in dns packet", off, "<", len(msg))
875
+ // // println("dns: extra bytes in dns packet", off, "<", len(msg))
876
876
// }
877
877
return err
878
878
}
@@ -1123,23 +1123,28 @@ func unpackQuestion(msg []byte, off int) (Question, int, error) {
1123
1123
)
1124
1124
q .Name , off , err = UnpackDomainName (msg , off )
1125
1125
if err != nil {
1126
- return q , off , err
1126
+ return q , off , fmt . Errorf ( "question.Name: %w" , err )
1127
1127
}
1128
1128
if off == len (msg ) {
1129
1129
return q , off , nil
1130
1130
}
1131
1131
q .Qtype , off , err = unpackUint16 (msg , off )
1132
1132
if err != nil {
1133
- return q , off , err
1133
+ return q , off , fmt . Errorf ( "question.Qtype: %w" , err )
1134
1134
}
1135
1135
if off == len (msg ) {
1136
1136
return q , off , nil
1137
1137
}
1138
1138
q .Qclass , off , err = unpackUint16 (msg , off )
1139
+ if err != nil {
1140
+ return q , off , fmt .Errorf ("question.Qclass: %w" , err )
1141
+ }
1142
+
1139
1143
if off == len (msg ) {
1140
1144
return q , off , nil
1141
1145
}
1142
- return q , off , err
1146
+
1147
+ return q , off , nil
1143
1148
}
1144
1149
1145
1150
func (dh * Header ) pack (msg []byte , off int , compression compressionMap , compress bool ) (int , error ) {
@@ -1177,27 +1182,27 @@ func unpackMsgHdr(msg []byte, off int) (Header, int, error) {
1177
1182
)
1178
1183
dh .Id , off , err = unpackUint16 (msg , off )
1179
1184
if err != nil {
1180
- return dh , off , err
1185
+ return dh , off , fmt . Errorf ( "header.Id: %w" , err )
1181
1186
}
1182
1187
dh .Bits , off , err = unpackUint16 (msg , off )
1183
1188
if err != nil {
1184
- return dh , off , err
1189
+ return dh , off , fmt . Errorf ( "header.Bits: %w" , err )
1185
1190
}
1186
1191
dh .Qdcount , off , err = unpackUint16 (msg , off )
1187
1192
if err != nil {
1188
- return dh , off , err
1193
+ return dh , off , fmt . Errorf ( "header.Qdcount: %w" , err )
1189
1194
}
1190
1195
dh .Ancount , off , err = unpackUint16 (msg , off )
1191
1196
if err != nil {
1192
- return dh , off , err
1197
+ return dh , off , fmt . Errorf ( "header.Ancount: %w" , err )
1193
1198
}
1194
1199
dh .Nscount , off , err = unpackUint16 (msg , off )
1195
1200
if err != nil {
1196
- return dh , off , err
1201
+ return dh , off , fmt . Errorf ( "header.Nscount: %w" , err )
1197
1202
}
1198
1203
dh .Arcount , off , err = unpackUint16 (msg , off )
1199
1204
if err != nil {
1200
- return dh , off , err
1205
+ return dh , off , fmt . Errorf ( "header.Arcount: %w" , err )
1201
1206
}
1202
1207
return dh , off , nil
1203
1208
}
0 commit comments