[prev in list] [next in list] [prev in thread] [next in thread]
List: bind-workers
Subject: Re: BIND 8.4.0-T1B fails to build on linux
From: Mark_Andrews () isc ! org
Date: 2003-04-15 4:33:54
[Download RAW message or body]
>
> If we are going to attack this function then lets do it
> fully.
>
> Mark
Take two.
Index: ns_samedomain.c
===================================================================
RCS file: /proj/cvs/isc/bind8/src/lib/nameser/ns_samedomain.c,v
retrieving revision 8.11
diff -u -r8.11 ns_samedomain.c
--- ns_samedomain.c 14 Apr 2003 14:52:48 -0000 8.11
+++ ns_samedomain.c 15 Apr 2003 04:31:59 -0000
@@ -165,18 +165,32 @@
int
ns_makecanon(const char *src, char *dst, size_t dstsize) {
size_t n = strlen(src);
+ int escaped;
+ int i;
+ /* Kill illegal empty labels at end. */
+ while (n > 1 && src[n - 1] == '.' && src[n - 2] == '.')
+ n--;
+ /* See if last period is escaped. */
+ if (n != 0 && src[n - 1] == '.') {
+ escaped = 0;
+ /* Note this loop doesn't get executed if n==1. */
+ for (i = (int)n - 2; i >= 0; i--)
+ if (src[i] == '\\') {
+ if (escaped)
+ escaped = 0;
+ else
+ escaped = 1;
+ } else
+ break;
+ if (!escaped)
+ n--;
+ }
if (n + sizeof "." > dstsize) { /* Note: sizeof == 2 */
errno = EMSGSIZE;
return (-1);
}
- strcpy(dst, src);
- while (n >= 1 && dst[n - 1] == '.') /* Ends in "." */
- if (n >= 2 && dst[n - 2] == '\\' && /* Ends in "\." */
- (n < 3 || dst[n - 3] != '\\')) /* But not "\\." */
- break;
- else
- dst[--n] = '\0';
+ strncpy(dst, src, n);
dst[n++] = '.';
dst[n] = '\0';
return (0);
--
Mark Andrews, Internet Software Consortium
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742 INTERNET: Mark.Andrews@isc.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic