A some length check to $GENERATE modifiers

Short cut these modifier lengths to 255 max. Which seems a reasonable default.
This commit is contained in:
Miek Gieben 2015-08-08 13:31:38 +01:00
parent 58c5f4cf6e
commit 3b3e522e22
2 changed files with 3 additions and 2 deletions

View File

@ -8,6 +8,7 @@ func TestFuzzString(t *testing.T) {
" NSAP O ", " NSAP N ",
" TYPE4 TYPE6a789a3bc0045c8a5fb42c7d1bd998f5444 IN 9579b47d46817afbd17273e6",
" TYPE45 3 3 4147994 TYPE\\(\\)\\)\\(\\)\\(\\(\\)\\(\\)\\)\\)\\(\\)\\(\\)\\(\\(\\R 948\"\")\\(\\)\\)\\)\\(\\ ",
"$GENERATE 0-3 ${441189,5039418474430,o}",
}
for i, tc := range testcases {
rr, err := NewRR(tc)

View File

@ -141,11 +141,11 @@ func modToPrintf(s string) (string, int, string) {
return "", 0, "bad base in $GENERATE"
}
offset, err := strconv.Atoi(xs[0])
if err != nil {
if err != nil || offset > 255 {
return "", 0, "bad offset in $GENERATE"
}
width, err := strconv.Atoi(xs[1])
if err != nil {
if err != nil || width > 255 {
return "", offset, "bad width in $GENERATE"
}
switch {