Diff for /embedaddon/dnsmasq/src/util.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2013/07/29 19:37:40 version 1.1.1.2, 2014/06/15 16:31:38
Line 1 Line 1
/* dnsmasq is Copyright (c) 2000-2013 Simon Kelley/* dnsmasq is Copyright (c) 2000-2014 Simon Kelley
   
    This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
Line 28 Line 28
 #include <idna.h>  #include <idna.h>
 #endif  #endif
   
 #ifdef HAVE_ARC4RANDOM  
 void rand_init(void)  
 {  
   return;  
 }  
   
 unsigned short rand16(void)  
 {  
    return (unsigned short) (arc4random() >> 15);  
 }  
   
 #else  
   
 /* SURF random number generator */  /* SURF random number generator */
   
 static u32 seed[32];  static u32 seed[32];
 static u32 in[12];  static u32 in[12];
 static u32 out[8];  static u32 out[8];
   static int outleft = 0;
   
 void rand_init()  void rand_init()
 {  {
Line 83  static void surf(void) Line 71  static void surf(void)
   
 unsigned short rand16(void)  unsigned short rand16(void)
 {  {
     if (!outleft) 
       {
         if (!++in[0]) if (!++in[1]) if (!++in[2]) ++in[3];
         surf();
         outleft = 8;
       }
     
     return (unsigned short) out[--outleft];
   }
   
   u64 rand64(void)
   {
   static int outleft = 0;    static int outleft = 0;
   
  if (!outleft) {  if (outleft < 2)
    if (!++in[0]) if (!++in[1]) if (!++in[2]) ++in[3];    {
    surf();      if (!++in[0]) if (!++in[1]) if (!++in[2]) ++in[3];
    outleft = 8;      surf();
  }      outleft = 8;
     }
   
   outleft -= 2;
   
  return (unsigned short) out[--outleft];  return (u64)out[outleft+1] + (((u64)out[outleft]) << 32);
 }  }
   
 #endif  
   
 static int check_name(char *in)  static int check_name(char *in)
 {  {
   /* remove trailing .     /* remove trailing . 
Line 108  static int check_name(char *in) Line 109  static int check_name(char *in)
       
   if (in[l-1] == '.')    if (in[l-1] == '.')
     {      {
       if (l == 1) return 0;  
       in[l-1] = 0;        in[l-1] = 0;
         nowhite = 1;
     }      }
  
   for (; (c = *in); in++)    for (; (c = *in); in++)
     {      {
       if (c == '.')        if (c == '.')
Line 142  static int check_name(char *in) Line 143  static int check_name(char *in)
 int legal_hostname(char *name)  int legal_hostname(char *name)
 {  {
   char c;    char c;
     int first;
   
   if (!check_name(name))    if (!check_name(name))
     return 0;      return 0;
   
  for (; (c = *name); name++)  for (first = 1; (c = *name); name++, first = 0)
     /* check for legal char a-z A-Z 0-9 - _ . */      /* check for legal char a-z A-Z 0-9 - _ . */
     {      {
       if ((c >= 'A' && c <= 'Z') ||        if ((c >= 'A' && c <= 'Z') ||
           (c >= 'a' && c <= 'z') ||            (c >= 'a' && c <= 'z') ||
          (c >= '0' && c <= '9') ||          (c >= '0' && c <= '9'))
          c == '-' || c == '_') 
         continue;          continue;
   
         if (!first && (c == '-' || c == '_'))
           continue;
               
       /* end of hostname part */        /* end of hostname part */
       if (c == '.')        if (c == '.')
Line 454  int parse_hex(char *in, unsigned char *out, int maxlen Line 458  int parse_hex(char *in, unsigned char *out, int maxlen
                   int j, bytes = (1 + (r - in))/2;                    int j, bytes = (1 + (r - in))/2;
                   for (j = 0; j < bytes; j++)                    for (j = 0; j < bytes; j++)
                     {                       { 
                      char sav;                      char sav = sav;
                       if (j < bytes - 1)                        if (j < bytes - 1)
                         {                          {
                           sav = in[(j+1)*2];                            sav = in[(j+1)*2];

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>