golang/go

x/net/dns/dnsmessage: does not support RFC 2673 bit-string labels

Open

#52.489 aperta il 22 apr 2022

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)Go (19.008 fork)batch import
NeedsInvestigationhelp wanted

Metriche repository

Star
 (133.883 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

What version of Go are you using (go version)?

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

What did you do?

` Here is TCP DNS payload hexStream := "00600006850000010001000100000776657273696f6e0462696e640000100003c00c0010000300000000002827392e382e327263312d5265644861742d392e382e322d302e36382e7263312e656c365f31302e38c00c00020003000000000002c00c"

data, _ := hex.DecodeString(hexStream)`

https://github.com/golang/net/blob/1d1ef9303861d099ec7e69ccb17377e0c443542d/dns/dnsmessage/message.go#L2041

  • wireshark code here

     case 0x40:
     //Extended label (RFC 2673) 
     switch (component_len & 0x3f) {
    
       case 0x01:
         /* Bitstring label */
       {
         int bit_count;
         int label_len;
         int print_len;
    
         bit_count = tvb_get_guint8(tvb, offset);
         offset++;
         label_len = (bit_count - 1) / 8 + 1;
    
         if (maxname > 0) {
           print_len = g_snprintf(np, maxname, "\\[x");
           if (print_len <= maxname) {
             np      += print_len;
             maxname -= print_len;
           } else {
             /* Nothing printed, as there's no room.
                Suppress all subsequent printing. */
             maxname = 0;
           }
         }
         while (label_len--) {
           if (maxname > 0) {
             print_len = g_snprintf(np, maxname, "%02x",
                                    tvb_get_guint8(tvb, offset));
             if (print_len <= maxname) {
               np      += print_len;
               maxname -= print_len;
             } else {
               /* Nothing printed, as there's no room.
                  Suppress all subsequent printing. */
               maxname = 0;
             }
           }
           offset++;
         }
         if (maxname > 0) {
           print_len = g_snprintf(np, maxname, "/%d]", bit_count);
           if (print_len <= maxname) {
             np      += print_len;
             maxname -= print_len;
           } else {
             /* Nothing printed, as there's no room.
                Suppress all subsequent printing. */
             maxname = 0;
           }
         }
       }
       break;
    
       default:
         *name="<Unknown extended label>";
         *name_len = (guint)strlen(*name);
         /* Parsing will probably fail from here on, since the */
         /* label length is unknown... */
         len = offset - start_offset;
         if (len < min_len) {
           THROW(ReportedBoundsError);
         }
         return len;
     }
     break;`
    

What did you expect to see?

image

What did you see instead?

Guida contributor