Skip to content

Commit

Permalink
Bug fix---use calculated max number of segments
Browse files Browse the repository at this point in the history
Per Tony Finch [1], the maximum number of segments are:

	I had a quick look and I noticed that it sets the maximum number of
	labels to 100.  The actual maximum is 128, because the maximum
	length of a DNS name is 255, and the minimum length of a label is 2
	(except for the root which is 1), and (255 - 1)/2 + 1 == 128.

https://lobste.rs/s/tukocy/network_protocols_sans_i_o_2016#c_495uaz
  • Loading branch information
spc476 committed Jun 26, 2024
1 parent 443697f commit d291537
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ UNAME := $(shell uname)
VERSION := $(shell git describe --tag)

ifeq ($(VERSION),)
VERSION=v2.1.0
VERSION=v2.1.3
endif

# ===================================================
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package = "org.conman.dns"
version = "2.1.0-1"
version = "2.1.3-1"
source = {
url = "git+https://github.com/spc476/SPCDNS.git",
tag = "v2.1.0"
tag = "v2.1.3"
}
description = {
summary = "A Lua module to encode DNS queries and decode DNS answers.",
Expand Down
9 changes: 5 additions & 4 deletions src/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@
/*---------------------------------------------------------------------------
; This is the maximum number of domain labels to encode. The domain
; "example.com" contains two domain labels. "1.0.0.127.in-addr.arpa" has
; six domain labels. This value is an arbitrary limit to avoid doing any
; memory allocations but I feel it's sufficiently large enough to avoid any
; limits. I hope.
; six domain labels. This value is calculated was calculated by Tony Finch
; [1] based upon the maximum domain name length, and minimum segment length.
;
; [1] https://lobste.rs/s/tukocy/network_protocols_sans_i_o_2016#c_495uaz
;----------------------------------------------------------------------------*/

#define MAXSEG 100
#define MAXSEG 128

/*---------------------------------------------------------------------------
; You really, no, I mean it, *REALLY* need to read RFC-1876 to understand
Expand Down

0 comments on commit d291537

Please sign in to comment.