chiark / gitweb /
@@ -1,3 +1,10 @@
[adns] / client / adnslogres.c
index 79d3da6b00cf5e90ce271e04df038fddb9c0d346..eb62656a1d3d1a8c2e07225047aa07c4560967c5 100644 (file)
@@ -30,7 +30,7 @@
  */
 
 static const char * const cvsid =
-       "$Id: adnslogres.c,v 1.7 1999/10/15 16:46:14 ian Exp $";
+       "$Id: adnslogres.c,v 1.8 2000/03/20 01:46:07 ian Exp $";
 
 #include <sys/types.h>
 #include <sys/time.h>
@@ -58,6 +58,9 @@ static const char *progname;
 
 #define msg(fmt, args...) fprintf(stderr, "%s: " fmt "\n", progname, ##args)
 
+#define sensible_ctype(type,ch) (type((unsigned char)(ch)))
+  /* isfoo() functions from ctype.h can't safely be fed char - blech ! */
+
 static void aargh(const char *cause) {
   const char *why = strerror(errno);
   if (!why) why = "Unknown error";
@@ -75,7 +78,7 @@ static char *ipaddr2domain(char *start, char **addr, char **rest) {
 
   ptrs[0]= start;
 retry:
-  while (!isdigit(*ptrs[0]))
+  while (!sensible_ctype(isdigit,*ptrs[0]))
     if (!*ptrs[0]++) {
       strcpy(buf, "invalid.");
       *addr= *rest= NULL;
@@ -83,8 +86,8 @@ retry:
     }
   for (i= 1; i < 5; i++) {
     ptrs[i]= ptrs[i-1];
-    while (isdigit(*ptrs[i]++));
-    if ((i == 4 && !isspace(ptrs[i][-1])) ||
+    while (sensible_ctype(isdigit,*ptrs[i]++));
+    if ((i == 4 && !sensible_ctype(isspace,ptrs[i][-1])) ||
        (i != 4 && ptrs[i][-1] != '.') ||
        (ptrs[i]-ptrs[i-1] > 4)) {
       ptrs[0]= ptrs[i]-1;