Changeset 630


Ignore:
Timestamp:
04/30/14 17:18:23 (11 years ago)
Author:
Kris Deugau
Message:

/trunk

Add a bit more validation in _validate_65280() (A+PTR) Just In Case.
See #53.

A+PTR and AAAA+PTR can have stricter validation because they're logical
representations of pairs of matched records; if there's a mismatch then
they should automatically be coerced down to single A, AAAA, or PTR
records as appropriate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r629 r630  
    10171017    # live record;  revrec determines whether we validate the PTR or A component first.
    10181018
     1019    # Fail early on non-IP gibberish in ${$args{val}}.  Arguably .arpa names might be acceptable
     1020    # but that gets stupid in forward zones, since these records are shared.
     1021    return ('FAIL', "$typemap{${$args{rectype}}} record must be a valid IPv4 address")
     1022      if ${$args{rectype}} == 65280 && ${$args{val}} !~ /^\d+\.\d+\.\d+\.\d+$/;
     1023    return ('FAIL', "$typemap{${$args{rectype}}} record must be a valid IPv6 address")
     1024      if ${$args{rectype}} == 65281 && ${$args{val}} !~ /^[a-fA-F0-9:]+$/;
     1025    # If things are not OK, this should prevent Stupid in the error log.
     1026    $args{addr} = new NetAddr::IP ${$args{val}}
     1027      or return ('FAIL', "$typemap{${$args{rectype}}} record must be a valid IPv".
     1028                        (${$args{rectype}} == 65280 ? '4' : '6')." address");
     1029    ${$args{val}} = $args{addr}->addr;
     1030
    10191031    if ($args{revrec} eq 'y') {
    10201032      ($code,$msg) = $self->_validate_12(%args);
     
    10781090      }
    10791091
    1080 #      my ($ptrcount) = $dbh->selectrow_array("SELECT count(*) FROM "._rectable($args{defrec},$args{revrec}).
    1081 #       " WHERE val = ?", undef, ${$args{val}});
    1082 #      if ($ptrcount) {
    1083 #        my $curid = $dbh->selectrow_array("SELECT record_id FROM "._rectable($args{defrec},$args{revrec}).
    1084 #               " WHERE val = ?
    1085 #       $msg = "PTR record for ${$args{val}} already exists;  adding another will probably not do what you want";
    1086 #       $code = 'WARN';
    1087 #      }
    1088 
     1092      # Add the reverse zone ID to the fieldlist
    10891093      ${$args{fields}} .= "rdns_id,";
    10901094      push @{$args{vallist}}, $revid;
     
    10921096
    10931097  } else {      # defrec eq 'y'
     1098
    10941099    if ($args{revrec} eq 'y') {
    10951100      ($code,$msg) = $self->_validate_12(%args);
Note: See TracChangeset for help on using the changeset viewer.