From: John Hodge Date: Tue, 17 Feb 2015 04:53:24 +0000 (+0800) Subject: Usermode/libnet - Fix compile errors (silly me) X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=6a28fd66345b484f9dfa5dba869888becdaf7112;p=tpg%2Facess2.git Usermode/libnet - Fix compile errors (silly me) --- diff --git a/Usermode/Libraries/libnet.so_src/dns.c b/Usermode/Libraries/libnet.so_src/dns.c index 9ac9198b..26bf99b1 100644 --- a/Usermode/Libraries/libnet.so_src/dns.c +++ b/Usermode/Libraries/libnet.so_src/dns.c @@ -23,6 +23,10 @@ int DNS_Query(int ServerAType, const void *ServerAddr, const char *name, enum eT { char packet[512]; size_t packlen = DNS_int_EncodeQuery(packet, sizeof(packet), name, type, class); + if( packlen == 0 ) { + _SysDebug("DNS_Query - Serialising packet failed"); + return 2; + } // Send and wait for reply // - Lock @@ -35,8 +39,8 @@ int DNS_Query(int ServerAType, const void *ServerAddr, const char *name, enum eT // TODO: Correctly report this failure with a useful error code return 1; } - int rv = Net_UDP_SendTo(sock, 53, ServerAType, ServerAddr, pos, packet); - if( rv != pos ) { + int rv = Net_UDP_SendTo(sock, 53, ServerAType, ServerAddr, packlen, packet); + if( rv != packlen ) { _SysDebug("DNS_Query - Write failed"); // TODO: Error reporting _SysClose(sock); diff --git a/Usermode/Libraries/libnet.so_src/hostnames.c b/Usermode/Libraries/libnet.so_src/hostnames.c index c3c96268..99aa328b 100644 --- a/Usermode/Libraries/libnet.so_src/hostnames.c +++ b/Usermode/Libraries/libnet.so_src/hostnames.c @@ -43,7 +43,7 @@ struct sDNSCallbackInfo // === PROTOTYPES === int int_lookupany_callback(void *info_v, int AddrType, const void *Addr); -void int_DNS_callback(void *info, const char *name, enum eTypes type, enum eClass class, unsigned int ttl, size_t rdlength, const void *rdata); + int int_DNS_callback(void *info, const char *name, enum eTypes type, enum eClass class, unsigned int ttl, size_t rdlength, const void *rdata); // === GLOBALS === int giNumDNSServers; @@ -127,22 +127,22 @@ int Net_Lookup_Addrs(const char *Name, void *cb_info, tNet_LookupAddrs_Callback return 1; } -void int_DNS_callback(void *info_v, const char *name, enum eTypes type, enum eClass class, unsigned int ttl, size_t rdlength, const void *rdata) +int int_DNS_callback(void *info_v, const char *name, enum eTypes type, enum eClass class, unsigned int ttl, size_t rdlength, const void *rdata) { struct sDNSCallbackInfo *info = info_v; _SysDebug("int_DNS_callback(name='%s', type=%i, class=%i)", name, type, class); // Check type matches (if pattern was provided) if( info->desired_type != QTYPE_STAR && type != info->desired_type ) - return ; + return 0; if( info->desired_class != QCLASS_STAR && class != info->desired_class ) - return ; + return 0; switch( type ) { case TYPE_A: if( rdlength != 4 ) - return ; + return 0; info->callback( info->cb_info, 4, rdata ); break; //case TYPE_AAAA: @@ -155,6 +155,7 @@ void int_DNS_callback(void *info_v, const char *name, enum eTypes type, enum eCl break; } info->got_value = true; + return 0; } int Net_Lookup_Name(int AddrType, const void *Addr, char *Dest[256])