Ignore:
Timestamp:
2010-08-11T02:05:34+02:00 (6 years ago)
Author:
jow
Message:

[package] uhttpd: add option to reject requests from RFC1918 IPs to public server IPs (DNS rebinding countermeasure)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/uhttpd/src/uhttpd-utils.c

    r22366 r22589  
    6060} 
    6161 
     62int sa_rfc1918(void *sa) 
     63{ 
     64        struct sockaddr_in *v4 = (struct sockaddr_in *)sa; 
     65        unsigned long a = htonl(v4->sin_addr.s_addr); 
     66 
     67        if( v4->sin_family == AF_INET ) 
     68        { 
     69                return ((a >= 0x0A000000) && (a <= 0x0AFFFFFF)) || 
     70                       ((a >= 0xAC100000) && (a <= 0xAC1FFFFF)) || 
     71                       ((a >= 0xC0A80000) && (a <= 0xC0A8FFFF)); 
     72        } 
     73 
     74        return 0; 
     75} 
     76 
    6277/* Simple strstr() like function that takes len arguments for both haystack and needle. */ 
    6378char *strfind(char *haystack, int hslen, const char *needle, int ndlen) 
Note: See TracChangeset for help on using the changeset viewer.