mirror of
https://github.com/coredns/coredns.git
synced 2026-01-09 02:11:18 -05:00
plugin: fix gosec G115 integer overflow warnings (#7799)
Fix integer overflow conversion warnings (G115) by adding appropriate suppressions where values are provably bounded. Fixes: https://github.com/coredns/coredns/issues/7793 Changes: - Updated 56 G115 annotations to use consistent // #nosec G115 format - Added 2 //nolint:gosec suppressions for conditional expressions - Removed G115 exclusion from golangci.yml (now explicitly handled per-line) Suppressions justify why each conversion is safe (e.g., port numbers are bounded 1-65535, DNS TTL limits, pool lengths, etc.) Signed-off-by: Azeez Syed <syedazeez337@gmail.com>
This commit is contained in:
@@ -53,7 +53,7 @@ func (w *DoQWriter) Close() error {
|
||||
// AddPrefix adds a 2-byte prefix with the DNS message length.
|
||||
func AddPrefix(b []byte) (m []byte) {
|
||||
m = make([]byte, 2+len(b))
|
||||
binary.BigEndian.PutUint16(m, uint16(len(b)))
|
||||
binary.BigEndian.PutUint16(m, uint16(len(b))) // #nosec G115 -- DNS message length fits in uint16
|
||||
copy(m[2:], b)
|
||||
|
||||
return m
|
||||
|
||||
@@ -101,7 +101,7 @@ func (s *ServergRPC) Serve(l net.Listener) error {
|
||||
|
||||
// Only set MaxConcurrentStreams if not unbounded (0)
|
||||
if s.maxStreams > 0 {
|
||||
serverOpts = append(serverOpts, grpc.MaxConcurrentStreams(uint32(s.maxStreams)))
|
||||
serverOpts = append(serverOpts, grpc.MaxConcurrentStreams(uint32(s.maxStreams))) // #nosec G115 -- maxStreams is bounded
|
||||
}
|
||||
|
||||
if s.Tracer() != nil {
|
||||
|
||||
@@ -363,7 +363,8 @@ func readDOQMessage(r io.Reader) ([]byte, error) {
|
||||
// A client or server receives a STREAM FIN before receiving all the bytes
|
||||
// for a message indicated in the 2-octet length field.
|
||||
// See https://www.rfc-editor.org/rfc/rfc9250#section-4.3.3-2.2
|
||||
if size != uint16(len(buf)) {
|
||||
//nolint:gosec
|
||||
if size != uint16(len(buf)) { // #nosec G115 -- buf length fits in uint16
|
||||
return nil, fmt.Errorf("message size does not match 2-byte prefix")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user