{"record":{"id":"bbe084682916d057","repo":"TechnitiumSoftware/DnsServer","slug":"boot-file-name-cannot-exceed-127-bytes-bbe084","errorCode":null,"errorMessage":"Boot file name cannot exceed 127 bytes.","messagePattern":"Boot file name cannot exceed 127 bytes\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dhcp/Scope.cs","lineNumber":2013,"sourceCode":"        public string ServerHostName\n        {\n            get { return _serverHostName; }\n            set\n            {\n                if ((value != null) && (value.Length >= 64))\n                    throw new ArgumentException(\"Server host name cannot exceed 63 bytes.\");\n\n                _serverHostName = value;\n            }\n        }\n\n        public string BootFileName\n        {\n            get { return _bootFileName; }\n            set\n            {\n                if ((value != null) && (value.Length >= 128))\n                    throw new ArgumentException(\"Boot file name cannot exceed 127 bytes.\");\n\n                _bootFileName = value;\n            }\n        }\n\n        public IPAddress RouterAddress\n        {\n            get { return _routerAddress; }\n            set\n            {\n                ValidateIpv4(value, nameof(RouterAddress));\n                _routerAddress = value;\n            }\n        }\n\n        public bool UseThisDnsServer\n        {\n            get { return _useThisDnsServer; }","sourceCodeStart":1995,"sourceCodeEnd":2031,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dhcp/Scope.cs#L1995-L2031","documentation":"Thrown by the BootFileName setter when a non-null value has Length >= 128. DHCP boot file names occupy the 128-byte 'file' field in the message, so values of 128 characters or more are rejected (max 127 usable).","triggerScenarios":"Assigning scope.BootFileName = value where value != null && value.Length >= 128. Happens with deeply nested PXE boot paths or absolute paths placed in the field.","commonSituations":"Config with a full absolute path, templated boot file strings, or unvalidated input that exceeds the DHCP file-field limit.","solutions":["Use a boot file name (path) of at most 127 characters before assignment.","Store longer paths elsewhere (e.g. an option) and pass a short reference here.","Validate input length in your config/UI layer.","For non-ASCII ensure the UTF-8 byte length stays under 128."],"exampleFix":"// before\nscope.BootFileName = bootPath; // may exceed 127\n\n// after\nscope.BootFileName = (bootPath == null || bootPath.Length <= 127) ? bootPath : bootPath.Substring(0, 127);","handlingStrategy":"validation","validationCode":"if (bootFile != null && Encoding.UTF8.GetByteCount(bootFile) >= 128)\n    throw new ConfigurationException(\"BootFileName must be <= 127 bytes\");\nscope.BootFileName = bootFile;","typeGuard":"static bool IsValidBootFileName(string s)\n    => s == null || Encoding.UTF8.GetByteCount(s) <= 127;","tryCatchPattern":"try { scope.BootFileName = value; }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Boot file name\"))\n{ /* shorten and retry */ }","preventionTips":["Pass a relative boot file path, not an absolute filesystem path.","Validate length (and UTF-8 byte length) in config.","Store long paths in a DHCP option instead of the file field."],"tags":["dhcp","validation","scope","string-length","pxe","argument"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}