From 407872aa95db606abf7d8cfa4226a15daa06e2b2 Mon Sep 17 00:00:00 2001 From: "nhotta%netscape.com" Date: Tue, 25 Mar 2003 20:48:03 +0000 Subject: [PATCH] Apply length check for generated ACE string, bug 198637, r=shanjian, sr=darin. git-svn-id: svn://10.0.0.236/trunk@140274 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/netwerk/dns/src/nsIDNService.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mozilla/netwerk/dns/src/nsIDNService.cpp b/mozilla/netwerk/dns/src/nsIDNService.cpp index 7f9ad7f6420..9b23cd03f5a 100644 --- a/mozilla/netwerk/dns/src/nsIDNService.cpp +++ b/mozilla/netwerk/dns/src/nsIDNService.cpp @@ -47,6 +47,7 @@ #include "punycode.h" //----------------------------------------------------------------------------- +// RFC 1034 - 3.1. Name space specifications and terminology static const PRUint32 kMaxDNSNodeLen = 63; //----------------------------------------------------------------------------- @@ -363,7 +364,7 @@ nsresult nsIDNService::stringPrepAndACE(const nsAString& in, nsACString& out) out.Truncate(); - if (in.Length() >= kMaxDNSNodeLen) { + if (in.Length() > kMaxDNSNodeLen) { NS_ERROR("IDN node too large"); return NS_ERROR_FAILURE; } @@ -377,6 +378,11 @@ nsresult nsIDNService::stringPrepAndACE(const nsAString& in, nsACString& out) rv = encodeToACE(strPrep, out); } + if (out.Length() > kMaxDNSNodeLen) { + NS_ERROR("IDN node too large"); + return NS_ERROR_FAILURE; + } + return rv; }