From: Ted Lemon Date: Wed, 2 May 2001 16:59:30 +0000 (+0000) Subject: If the algorithm name is not properly terminated with a '.', add one. X-Git-Tag: V3-RC5~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=351556132fcbcca56c2a5cf99360839a6a455639;p=thirdparty%2Fdhcp.git If the algorithm name is not properly terminated with a '.', add one. --- diff --git a/common/parse.c b/common/parse.c index 381c81844..9c8e5dbe3 100644 --- a/common/parse.c +++ b/common/parse.c @@ -43,7 +43,7 @@ #ifndef lint static char copyright[] = -"$Id: parse.c,v 1.103 2001/04/09 00:41:45 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n"; +"$Id: parse.c,v 1.104 2001/05/02 16:59:30 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -2214,20 +2214,32 @@ int parse_key (struct parse *cfile) goto rbad; /* If the algorithm name isn't an FQDN, tack on the .SIG-ALG.REG.NET. domain. */ - s = strchr (key -> algorithm, '.'); + s = strrchr (key -> algorithm, '.'); if (!s) { - static char add [] = ".SIG-ALG.REG.INT."; - s = dmalloc (strlen (key -> algorithm) + - sizeof (add), MDL); - if (!s) { - log_error ("no memory for key %s.", - "algorithm"); - goto rbad; - } - strcpy (s, key -> algorithm); - strcat (s, add); - dfree (key -> algorithm, MDL); - key -> algorithm = s; + static char add [] = ".SIG-ALG.REG.INT."; + s = dmalloc (strlen (key -> algorithm) + + sizeof (add), MDL); + if (!s) { + log_error ("no memory for key %s.", + "algorithm"); + goto rbad; + } + strcpy (s, key -> algorithm); + strcat (s, add); + dfree (key -> algorithm, MDL); + key -> algorithm = s; + } else if (s [1]) { + /* If there is no trailing '.', hack one in. */ + s = dmalloc (strlen (key -> algorithm) + 2, MDL); + if (!s) { + log_error ("no memory for key %s.", + key -> algorithm); + goto rbad; + } + strcpy (s, key -> algorithm); + strcat (s, "."); + dfree (key -> algorithm, MDL); + key -> algorithm = s; } break;