Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/lib/addns
Files:
2 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/lib/addns/dns.h

    r740 r988  
    2828#include "../replace/replace.h"
    2929#include "system/network.h"
     30#include "system/kerberos.h"
     31#include "system/gssapi.h"
    3032
    3133/* make sure we have included the correct config.h */
     
    3739#endif /* NO_CONFIG_H */
    3840
    39 #include <stdio.h>
    40 #include <stdlib.h>
    4141#include <fcntl.h>
    4242#include <time.h>
    43 #include <string.h>
    44 #include <errno.h>
    4543#include <netdb.h>
    46 #include <sys/types.h>
    47 #include <sys/socket.h>
    48 #include <netinet/in.h>
    49 #include <arpa/inet.h>
    50 #include <stdarg.h>
    51 
    52 #ifdef HAVE_UUID_UUID_H
    53 #include <uuid/uuid.h>
    54 #endif
    55 
    56 #ifdef HAVE_KRB5_H
    57 #include <krb5.h>
    58 #endif
    59 
    60 #ifdef HAVE_INTTYPES_H
    61 #include <inttypes.h>
    62 
    63 #ifndef int16
    64 #define int16 int16_t
    65 #endif
    66 
    67 #ifndef uint16
    68 #define uint16 uint16_t
    69 #endif
    70 
    71 #ifndef int32
    72 #define int32 int32_t
    73 #endif
    74 
    75 #ifndef uint32
    76 #define uint32 uint32_t
    77 #endif
    78 #endif
    79 
    80 #ifdef HAVE_KRB5_H
    81 #include <krb5.h>
    82 #endif
    83 
    84 #if HAVE_GSSAPI_GSSAPI_H
    85 #include <gssapi/gssapi.h>
    86 #elif HAVE_GSSAPI_GSSAPI_GENERIC_H
    87 #include <gssapi/gssapi_generic.h>
    88 #elif HAVE_GSSAPI_H
    89 #include <gssapi.h>
    90 #endif
    91 
    92 #if defined(HAVE_GSSAPI_H) || defined(HAVE_GSSAPI_GSSAPI_H) || defined(HAVE_GSSAPI_GSSAPI_GENERIC_H)
    93 #define HAVE_GSSAPI_SUPPORT    1
    94 #endif
    9544
    9645#include <talloc.h>
    97 
    98 #if 0
    99 
    100 Disable these now we have checked all code paths and ensured
    101 NULL returns on zero request. JRA.
    102 
    103 void *_talloc_zero_zeronull(const void *ctx, size_t size, const char *name);
    104 void *_talloc_memdup_zeronull(const void *t, const void *p, size_t size, const char *name);
    105 void *_talloc_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name);
    106 void *_talloc_zero_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name);
    107 void *talloc_zeronull(const void *context, size_t size, const char *name);
    108 
    109 #define TALLOC(ctx, size) talloc_zeronull(ctx, size, __location__)
    110 #define TALLOC_P(ctx, type) (type *)talloc_zeronull(ctx, sizeof(type), #type)
    111 #define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array_zeronull(ctx, sizeof(type), count, #type)
    112 #define TALLOC_MEMDUP(ctx, ptr, size) _talloc_memdup_zeronull(ctx, ptr, size, __location__)
    113 #define TALLOC_ZERO(ctx, size) _talloc_zero_zeronull(ctx, size, __location__)
    114 #define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero_zeronull(ctx, sizeof(type), #type)
    115 #define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array_zeronull(ctx, sizeof(type), count, #type)
    116 #define TALLOC_SIZE(ctx, size) talloc_zeronull(ctx, size, __location__)
    117 #define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero_zeronull(ctx, size, __location__)
    118 
    119 #else
    120 
    121 #define TALLOC(ctx, size) talloc_named_const(ctx, size, __location__)
    122 #define TALLOC_P(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)
    123 #define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type)
    124 #define TALLOC_MEMDUP(ctx, ptr, size) _talloc_memdup(ctx, ptr, size, __location__)
    125 #define TALLOC_ZERO(ctx, size) _talloc_zero(ctx, size, __location__)
    126 #define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
    127 #define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type)
    128 #define TALLOC_SIZE(ctx, size) talloc_named_const(ctx, size, __location__)
    129 #define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero(ctx, size, __location__)
    130 
    131 #endif
    132 
    133 #define TALLOC_REALLOC(ctx, ptr, count) _talloc_realloc(ctx, ptr, count, __location__)
    134 #define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type)
    135 #define talloc_destroy(ctx) talloc_free(ctx)
    136 #ifndef TALLOC_FREE
    137 #define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
    138 #endif
    139 
    140 /*******************************************************************
    141    Type definitions for int16, int32, uint16 and uint32.  Needed
    142    for Samba coding style
    143 *******************************************************************/
    144 
    145 #ifndef uint8
    146 #  define uint8 unsigned char
    147 #endif
    148 
    149 #if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
    150 #  if (SIZEOF_SHORT == 4)
    151 #    define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
    152 #  else /* SIZEOF_SHORT != 4 */
    153 #    define int16 short
    154 #  endif /* SIZEOF_SHORT != 4 */
    155    /* needed to work around compile issue on HP-UX 11.x */
    156 #  define _INT16        1
    157 #endif
    158 
    159 /*
    160  * Note we duplicate the size tests in the unsigned
    161  * case as int16 may be a typedef from rpc/rpc.h
    162  */
    163 
    164 #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
    165 #  if (SIZEOF_SHORT == 4)
    166 #    define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
    167 #  else /* SIZEOF_SHORT != 4 */
    168 #    define uint16 unsigned short
    169 #  endif /* SIZEOF_SHORT != 4 */
    170 #endif
    171 
    172 #if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H)
    173 #  if (SIZEOF_INT == 4)
    174 #    define int32 int
    175 #  elif (SIZEOF_LONG == 4)
    176 #    define int32 long
    177 #  elif (SIZEOF_SHORT == 4)
    178 #    define int32 short
    179 #  else
    180      /* uggh - no 32 bit type?? probably a CRAY. just hope this works ... */
    181 #    define int32 int
    182 #  endif
    183 #  ifndef _INT32
    184      /* needed to work around compile issue on HP-UX 11.x */
    185 #    define _INT32        1
    186 #  endif
    187 #endif
    188 
    189 /*
    190  * Note we duplicate the size tests in the unsigned
    191  * case as int32 may be a typedef from rpc/rpc.h
    192  */
    193 
    194 #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
    195 #  if (SIZEOF_INT == 4)
    196 #    define uint32 unsigned int
    197 #  elif (SIZEOF_LONG == 4)
    198 #    define uint32 unsigned long
    199 #  elif (SIZEOF_SHORT == 4)
    200 #    define uint32 unsigned short
    201 #  else
    202       /* uggh - no 32 bit type?? probably a CRAY. just hope this works ... */
    203 #    define uint32 unsigned
    204 #  endif
    205 #endif
    206 
    207 /*
    208  * check for 8 byte long long
    209  */
    210 
    211 #if !defined(uint64)
    212 #  if (SIZEOF_LONG == 8)
    213 #    define uint64 unsigned long
    214 #  elif (SIZEOF_LONG_LONG == 8)
    215 #    define uint64 unsigned long long
    216 #  endif /* don't lie.  If we don't have it, then don't use it */
    217 #endif
    218 
    219 /* needed on Sun boxes */
    220 #ifndef INADDR_NONE
    221 #define INADDR_NONE          0xFFFFFFFF
    222 #endif
    22346
    22447#include "dnserr.h"
     
    24871#define QTYPE_CNAME     5
    24972#define QTYPE_SOA       6
     73#define QTYPE_AAAA      28
    25074#define QTYPE_ANY       255
    25175#define QTYPE_TKEY      249
     
    329153struct dns_question {
    330154        struct dns_domain_name *name;
    331         uint16 q_type;
    332         uint16 q_class;
     155        uint16_t q_type;
     156        uint16_t q_class;
    333157};
    334158
     
    341165struct dns_zone {
    342166        struct dns_domain_name *name;
    343         uint16 z_type;
    344         uint16 z_class;
     167        uint16_t z_type;
     168        uint16_t z_class;
    345169};
    346170
    347171struct dns_rrec {
    348172        struct dns_domain_name *name;
    349         uint16 type;
    350         uint16 r_class;
    351         uint32 ttl;
    352         uint16 data_length;
    353         uint8 *data;
     173        uint16_t type;
     174        uint16_t r_class;
     175        uint32_t ttl;
     176        uint16_t data_length;
     177        uint8_t *data;
    354178};
    355179
     
    358182        time_t inception;
    359183        time_t expiration;
    360         uint16 mode;
    361         uint16 error;
    362         uint16 key_length;
    363         uint8 *key;
     184        uint16_t mode;
     185        uint16_t error;
     186        uint16_t key_length;
     187        uint8_t *key;
    364188};
    365189
    366190struct dns_request {
    367         uint16 id;
    368         uint16 flags;
    369         uint16 num_questions;
    370         uint16 num_answers;
    371         uint16 num_auths;
    372         uint16 num_additionals;
     191        uint16_t id;
     192        uint16_t flags;
     193        uint16_t num_questions;
     194        uint16_t num_answers;
     195        uint16_t num_auths;
     196        uint16_t num_additionals;
    373197        struct dns_question **questions;
    374198        struct dns_rrec **answers;
     
    384208
    385209struct dns_update_request {
    386         uint16 id;
    387         uint16 flags;
    388         uint16 num_zones;
    389         uint16 num_preqs;
    390         uint16 num_updates;
    391         uint16 num_additionals;
     210        uint16_t id;
     211        uint16_t flags;
     212        uint16_t num_zones;
     213        uint16_t num_preqs;
     214        uint16_t num_updates;
     215        uint16_t num_additionals;
    392216        struct dns_zone **zones;
    393217        struct dns_rrec **preqs;
     
    397221
    398222struct dns_connection {
    399         int32 hType;
     223        int32_t hType;
    400224        int s;
    401         struct sockaddr RecvAddr;
     225        struct sockaddr_storage RecvAddr;
    402226};
    403227
    404228struct dns_buffer {
    405         uint8 *data;
     229        uint8_t *data;
    406230        size_t size;
    407231        size_t offset;
     
    419243
    420244DNS_ERROR dns_create_query( TALLOC_CTX *mem_ctx, const char *name,
    421                             uint16 q_type, uint16 q_class,
     245                            uint16_t q_type, uint16_t q_class,
    422246                            struct dns_request **preq );
    423247DNS_ERROR dns_create_update( TALLOC_CTX *mem_ctx, const char *name,
     
    428252                           struct dns_update_request **preq);
    429253DNS_ERROR dns_create_rrec(TALLOC_CTX *mem_ctx, const char *name,
    430                           uint16 type, uint16 r_class, uint32 ttl,
    431                           uint16 data_length, uint8 *data,
     254                          uint16_t type, uint16_t r_class, uint32_t ttl,
     255                          uint16_t data_length, uint8_t *data,
    432256                          struct dns_rrec **prec);
    433257DNS_ERROR dns_add_rrec(TALLOC_CTX *mem_ctx, struct dns_rrec *rec,
    434                        uint16 *num_records, struct dns_rrec ***records);
     258                       uint16_t *num_records, struct dns_rrec ***records);
    435259DNS_ERROR dns_create_tkey_record(TALLOC_CTX *mem_ctx, const char *keyname,
    436260                                 const char *algorithm_name, time_t inception,
    437                                  time_t expiration, uint16 mode, uint16 error,
    438                                  uint16 key_length, const uint8 *key,
     261                                 time_t expiration, uint16_t mode, uint16_t error,
     262                                 uint16_t key_length, const uint8_t *key,
    439263                                 struct dns_rrec **prec);
    440264DNS_ERROR dns_create_name_in_use_record(TALLOC_CTX *mem_ctx,
     
    443267                                        struct dns_rrec **prec);
    444268DNS_ERROR dns_create_delete_record(TALLOC_CTX *mem_ctx, const char *name,
    445                                    uint16 type, uint16 r_class,
     269                                   uint16_t type, uint16_t r_class,
    446270                                   struct dns_rrec **prec);
    447271DNS_ERROR dns_create_name_not_in_use_record(TALLOC_CTX *mem_ctx,
    448                                             const char *name, uint32 type,
     272                                            const char *name, uint32_t type,
    449273                                            struct dns_rrec **prec);
    450274DNS_ERROR dns_create_a_record(TALLOC_CTX *mem_ctx, const char *host,
    451                               uint32 ttl, const struct sockaddr_storage *pss,
     275                              uint32_t ttl, const struct sockaddr_storage *pss,
    452276                              struct dns_rrec **prec);
     277DNS_ERROR dns_create_aaaa_record(TALLOC_CTX *mem_ctx, const char *host,
     278                                 uint32_t ttl, const struct sockaddr_storage *pss,
     279                                 struct dns_rrec **prec);
    453280DNS_ERROR dns_unmarshall_tkey_record(TALLOC_CTX *mem_ctx, struct dns_rrec *rec,
    454281                                     struct dns_tkey_record **ptkey);
    455282DNS_ERROR dns_create_tsig_record(TALLOC_CTX *mem_ctx, const char *keyname,
    456283                                 const char *algorithm_name,
    457                                  time_t time_signed, uint16 fudge,
    458                                  uint16 mac_length, const uint8 *mac,
    459                                  uint16 original_id, uint16 error,
     284                                 time_t time_signed, uint16_t fudge,
     285                                 uint16_t mac_length, const uint8_t *mac,
     286                                 uint16_t original_id, uint16_t error,
    460287                                 struct dns_rrec **prec);
    461288DNS_ERROR dns_add_rrec(TALLOC_CTX *mem_ctx, struct dns_rrec *rec,
    462                        uint16 *num_records, struct dns_rrec ***records);
     289                       uint16_t *num_records, struct dns_rrec ***records);
    463290DNS_ERROR dns_create_update_request(TALLOC_CTX *mem_ctx,
    464291                                    const char *domainname,
     
    470297/* from dnssock.c */
    471298
    472 DNS_ERROR dns_open_connection( const char *nameserver, int32 dwType,
     299DNS_ERROR dns_open_connection( const char *nameserver, int32_t dwType,
    473300                    TALLOC_CTX *mem_ctx,
    474301                    struct dns_connection **conn );
     
    487314
    488315struct dns_buffer *dns_create_buffer(TALLOC_CTX *mem_ctx);
    489 void dns_marshall_buffer(struct dns_buffer *buf, const uint8 *data,
     316void dns_marshall_buffer(struct dns_buffer *buf, const uint8_t *data,
    490317                         size_t len);
    491 void dns_marshall_uint16(struct dns_buffer *buf, uint16 val);
    492 void dns_marshall_uint32(struct dns_buffer *buf, uint32 val);
    493 void dns_unmarshall_buffer(struct dns_buffer *buf, uint8 *data,
     318void dns_marshall_uint16(struct dns_buffer *buf, uint16_t val);
     319void dns_marshall_uint32(struct dns_buffer *buf, uint32_t val);
     320void dns_unmarshall_buffer(struct dns_buffer *buf, uint8_t *data,
    494321                           size_t len);
    495 void dns_unmarshall_uint16(struct dns_buffer *buf, uint16 *val);
    496 void dns_unmarshall_uint32(struct dns_buffer *buf, uint32 *val);
     322void dns_unmarshall_uint16(struct dns_buffer *buf, uint16_t *val);
     323void dns_unmarshall_uint32(struct dns_buffer *buf, uint32_t *val);
    497324void dns_unmarshall_domain_name(TALLOC_CTX *mem_ctx,
    498325                                struct dns_buffer *buf,
     
    517344struct dns_request *dns_update2request(struct dns_update_request *update);
    518345struct dns_update_request *dns_request2update(struct dns_request *request);
    519 uint16 dns_response_code(uint16 flags);
     346uint16_t dns_response_code(uint16_t flags);
    520347const char *dns_errstr(DNS_ERROR err);
    521348
    522349/* from dnsgss.c */
    523350
    524 #ifdef HAVE_GSSAPI_SUPPORT
     351#ifdef HAVE_GSSAPI
    525352
    526353void display_status( const char *msg, OM_uint32 maj_stat, OM_uint32 min_stat );
     
    534361                          const char *keyname,
    535362                          const char *algorithmname,
    536                           time_t time_signed, uint16 fudge);
    537 
    538 #endif  /* HAVE_GSSAPI_SUPPORT */
     363                          time_t time_signed, uint16_t fudge);
     364
     365#endif  /* HAVE_GSSAPI */
    539366
    540367#endif  /* _DNS_H */
  • vendor/current/lib/addns/dnserr.h

    r740 r988  
    3737
    3838#if defined(HAVE_IMMEDIATE_STRUCTURES)
    39 typedef struct {uint32 v;} DNS_ERROR;
     39typedef struct {uint32_t v;} DNS_ERROR;
    4040#define ERROR_DNS(x) ((DNS_ERROR) { x })
    4141#define ERROR_DNS_V(x) ((x).v)
    4242#else
    43 typedef uint32 DNS_ERROR;
     43typedef uint32_t DNS_ERROR;
    4444#define ERROR_DNS(x) (x)
    4545#define ERROR_DNS_V(x) (x)
  • vendor/current/lib/addns/dnsgss.c

    r860 r988  
    2727
    2828
    29 #ifdef HAVE_GSSAPI_SUPPORT
     29#ifdef HAVE_GSSAPI
    3030
    3131/*********************************************************************
     
    9393
    9494        gss_OID_desc krb5_oid_desc =
    95                 { 9, (char *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02" };
     95                { 9, discard_const("\x2a\x86\x48\x86\xf7\x12\x01\x02\x02") };
    9696
    9797        *ctx = GSS_C_NO_CONTEXT;
     
    126126                                req, keyname, "gss.microsoft.com", t,
    127127                                t + 86400, DNS_TKEY_MODE_GSSAPI, 0,
    128                                 output_desc.length, (uint8 *)output_desc.value,
     128                                output_desc.length, (uint8_t *)output_desc.value,
    129129                                &rec );
    130130                        if (!ERR_DNS_IS_OK(err)) goto error;
     
    231231
    232232        gss_OID_desc nt_host_oid_desc =
    233                 {10, (char *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x01"};
     233                {10, discard_const("\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x01")};
    234234
    235235        TALLOC_CTX *mem_ctx;
     
    281281                          const char *keyname,
    282282                          const char *algorithmname,
    283                           time_t time_signed, uint16 fudge)
     283                          time_t time_signed, uint16_t fudge)
    284284{
    285285        struct dns_buffer *buf;
     
    328328
    329329        err = dns_create_tsig_record(buf, keyname, algorithmname, time_signed,
    330                                      fudge, mic.length, (uint8 *)mic.value,
     330                                     fudge, mic.length, (uint8_t *)mic.value,
    331331                                     req->id, 0, &rec);
    332332        gss_release_buffer(&minor, &mic);
     
    340340}
    341341
    342 #endif  /* HAVE_GSSAPI_SUPPORT */
     342#endif  /* HAVE_GSSAPI */
  • vendor/current/lib/addns/dnsmarshall.c

    r746 r988  
    4040        result->size = 2;
    4141
    42         if (!(result->data = TALLOC_ZERO_ARRAY(result, uint8, result->size))) {
     42        if (!(result->data = talloc_zero_array(result, uint8_t, result->size))) {
    4343                TALLOC_FREE(result);
    4444                return NULL;
     
    4848}
    4949
    50 void dns_marshall_buffer(struct dns_buffer *buf, const uint8 *data,
     50void dns_marshall_buffer(struct dns_buffer *buf, const uint8_t *data,
    5151                         size_t len)
    5252{
     
    7171        if (buf->offset + len > buf->size) {
    7272                size_t new_size = buf->offset + len;
    73                 uint8 *new_data;
     73                uint8_t *new_data;
    7474
    7575                /*
     
    7979                new_size += (64 - (new_size % 64));
    8080
    81                 if (!(new_data = TALLOC_REALLOC_ARRAY(buf, buf->data, uint8,
     81                if (!(new_data = talloc_realloc(buf, buf->data, uint8_t,
    8282                                                      new_size))) {
    8383                        buf->error = ERROR_DNS_NO_MEMORY;
     
    9494}
    9595
    96 void dns_marshall_uint16(struct dns_buffer *buf, uint16 val)
    97 {
    98         uint16 n_val = htons(val);
    99         dns_marshall_buffer(buf, (uint8 *)&n_val, sizeof(n_val));
    100 }
    101 
    102 void dns_marshall_uint32(struct dns_buffer *buf, uint32 val)
    103 {
    104         uint32 n_val = htonl(val);
    105         dns_marshall_buffer(buf, (uint8 *)&n_val, sizeof(n_val));
    106 }
    107 
    108 void dns_unmarshall_buffer(struct dns_buffer *buf, uint8 *data,
     96void dns_marshall_uint16(struct dns_buffer *buf, uint16_t val)
     97{
     98        uint16_t n_val = htons(val);
     99        dns_marshall_buffer(buf, (uint8_t *)&n_val, sizeof(n_val));
     100}
     101
     102void dns_marshall_uint32(struct dns_buffer *buf, uint32_t val)
     103{
     104        uint32_t n_val = htonl(val);
     105        dns_marshall_buffer(buf, (uint8_t *)&n_val, sizeof(n_val));
     106}
     107
     108void dns_unmarshall_buffer(struct dns_buffer *buf, uint8_t *data,
    109109                           size_t len)
    110110{
     
    122122}
    123123
    124 void dns_unmarshall_uint16(struct dns_buffer *buf, uint16 *val)
    125 {
    126         uint16 n_val;
    127 
    128         dns_unmarshall_buffer(buf, (uint8 *)&n_val, sizeof(n_val));
     124void dns_unmarshall_uint16(struct dns_buffer *buf, uint16_t *val)
     125{
     126        uint16_t n_val;
     127
     128        dns_unmarshall_buffer(buf, (uint8_t *)&n_val, sizeof(n_val));
    129129        if (!(ERR_DNS_IS_OK(buf->error))) return;
    130130
     
    132132}
    133133
    134 void dns_unmarshall_uint32(struct dns_buffer *buf, uint32 *val)
    135 {
    136         uint32 n_val;
    137 
    138         dns_unmarshall_buffer(buf, (uint8 *)&n_val, sizeof(n_val));
     134void dns_unmarshall_uint32(struct dns_buffer *buf, uint32_t *val)
     135{
     136        uint32_t n_val;
     137
     138        dns_unmarshall_buffer(buf, (uint8_t *)&n_val, sizeof(n_val));
    139139        if (!(ERR_DNS_IS_OK(buf->error))) return;
    140140
     
    153153
    154154        for (label = name->pLabelList; label != NULL; label = label->next) {
    155                 uint8 len = label->len;
    156 
    157                 dns_marshall_buffer(buf, (uint8 *)&len, sizeof(len));
     155                uint8_t len = label->len;
     156
     157                dns_marshall_buffer(buf, (uint8_t *)&len, sizeof(len));
    158158                if (!ERR_DNS_IS_OK(buf->error)) return;
    159159
    160                 dns_marshall_buffer(buf, (uint8 *)label->label, len);
     160                dns_marshall_buffer(buf, (uint8_t *)label->label, len);
    161161                if (!ERR_DNS_IS_OK(buf->error)) return;
    162162        }
    163163
    164         dns_marshall_buffer(buf, (uint8 *)&end_char, 1);
     164        dns_marshall_buffer(buf, (uint8_t *)&end_char, 1);
    165165}
    166166
     
    171171{
    172172        struct dns_domain_label *label;
    173         uint8 len;
     173        uint8_t len;
    174174
    175175        if (!ERR_DNS_IS_OK(buf->error)) return;
     
    197197                 */
    198198                struct dns_buffer new_buf;
    199                 uint8 low;
     199                uint8_t low;
    200200
    201201                dns_unmarshall_buffer(buf, &low, sizeof(low));
     
    224224        label->len = len;
    225225
    226         if (!(label->label = TALLOC_ZERO_ARRAY(label, char, len+1))) {
     226        if (!(label->label = talloc_zero_array(label, char, len+1))) {
    227227                buf->error = ERROR_DNS_NO_MEMORY;
    228228                goto error;
    229229        }
    230230
    231         dns_unmarshall_buffer(buf, (uint8 *)label->label, len);
     231        dns_unmarshall_buffer(buf, (uint8_t *)label->label, len);
    232232        if (!ERR_DNS_IS_OK(buf->error)) goto error;
    233233
     
    330330
    331331        if (r->data_length != 0) {
    332                 if (!(r->data = TALLOC_ZERO_ARRAY(r, uint8, r->data_length))) {
     332                if (!(r->data = talloc_zero_array(r, uint8_t, r->data_length))) {
    333333                        buf->error = ERROR_DNS_NO_MEMORY;
    334334                        return;
     
    347347{
    348348        struct dns_buffer *buf;
    349         uint16 i;
     349        uint16_t i;
    350350
    351351        if (!(buf = dns_create_buffer(mem_ctx))) {
     
    388388{
    389389        struct dns_request *req;
    390         uint16 i;
     390        uint16_t i;
    391391        DNS_ERROR err;
    392392
    393         if (!(req = TALLOC_ZERO_P(mem_ctx, struct dns_request))) {
     393        if (!(req = talloc_zero(mem_ctx, struct dns_request))) {
    394394                return ERROR_DNS_NO_MEMORY;
    395395        }
     
    407407
    408408        if ((req->num_questions != 0) &&
    409             !(req->questions = TALLOC_ZERO_ARRAY(req, struct dns_question *,
     409            !(req->questions = talloc_zero_array(req, struct dns_question *,
    410410                                            req->num_questions))) {
    411411                goto error;
    412412        }
    413413        if ((req->num_answers != 0) &&
    414             !(req->answers = TALLOC_ZERO_ARRAY(req, struct dns_rrec *,
     414            !(req->answers = talloc_zero_array(req, struct dns_rrec *,
    415415                                          req->num_answers))) {
    416416                goto error;
    417417        }
    418418        if ((req->num_auths != 0) &&
    419             !(req->auths = TALLOC_ZERO_ARRAY(req, struct dns_rrec *,
     419            !(req->auths = talloc_zero_array(req, struct dns_rrec *,
    420420                                        req->num_auths))) {
    421421                goto error;
    422422        }
    423423        if ((req->num_additionals != 0) &&
    424             !(req->additionals = TALLOC_ZERO_ARRAY(req, struct dns_rrec *,
     424            !(req->additionals = talloc_zero_array(req, struct dns_rrec *,
    425425                                              req->num_additionals))) {
    426426                goto error;
     
    525525}
    526526
    527 uint16 dns_response_code(uint16 flags)
     527uint16_t dns_response_code(uint16_t flags)
    528528{
    529529        return flags & 0xF;
  • vendor/current/lib/addns/dnsrecord.c

    r746 r988  
    2323
    2424#include "dns.h"
     25#include "lib/util/genrand.h"
    2526
    2627DNS_ERROR dns_create_query( TALLOC_CTX *mem_ctx, const char *name,
    27                             uint16 q_type, uint16 q_class,
     28                            uint16_t q_type, uint16_t q_class,
    2829                            struct dns_request **preq )
    2930{
     
    3233        DNS_ERROR err;
    3334
    34         if (!(req = TALLOC_ZERO_P(mem_ctx, struct dns_request)) ||
    35             !(req->questions = TALLOC_ARRAY(req, struct dns_question *, 1)) ||
     35        if (!(req = talloc_zero(mem_ctx, struct dns_request)) ||
     36            !(req->questions = talloc_array(req, struct dns_question *, 1)) ||
    3637            !(req->questions[0] = talloc(req->questions,
    3738                                         struct dns_question))) {
     
    4041        }
    4142
    42         req->id = random();
     43        generate_random_buffer((uint8_t *)&req->id, sizeof(req->id));
    4344
    4445        req->num_questions = 1;
     
    6566        DNS_ERROR err;
    6667
    67         if (!(req = TALLOC_ZERO_P(mem_ctx, struct dns_update_request)) ||
    68             !(req->zones = TALLOC_ARRAY(req, struct dns_zone *, 1)) ||
     68        if (!(req = talloc_zero(mem_ctx, struct dns_update_request)) ||
     69            !(req->zones = talloc_array(req, struct dns_zone *, 1)) ||
    6970            !(req->zones[0] = talloc(req->zones, struct dns_zone))) {
    7071                TALLOC_FREE(req);
     
    9293
    9394DNS_ERROR dns_create_rrec(TALLOC_CTX *mem_ctx, const char *name,
    94                           uint16 type, uint16 r_class, uint32 ttl,
    95                           uint16 data_length, uint8 *data,
     95                          uint16_t type, uint16_t r_class, uint32_t ttl,
     96                          uint16_t data_length, uint8_t *data,
    9697                          struct dns_rrec **prec)
    9798{
     
    120121
    121122DNS_ERROR dns_create_a_record(TALLOC_CTX *mem_ctx, const char *host,
    122                               uint32 ttl, const struct sockaddr_storage *pss,
     123                              uint32_t ttl, const struct sockaddr_storage *pss,
    123124                              struct dns_rrec **prec)
    124125{
    125         uint8 *data;
     126        uint8_t *data;
    126127        DNS_ERROR err;
    127128        struct in_addr ip;
    128129
    129130        if (pss->ss_family != AF_INET) {
    130                 /* Silently ignore this. */
    131                 return ERROR_DNS_SUCCESS;
    132         }
    133 
    134         ip = ((struct sockaddr_in *)pss)->sin_addr;
    135         if (!(data = (uint8 *)TALLOC_MEMDUP(mem_ctx, (const void *)&ip.s_addr,
     131                return ERROR_DNS_INVALID_PARAMETER;
     132        }
     133
     134        ip = ((const struct sockaddr_in *)pss)->sin_addr;
     135        if (!(data = (uint8_t *)talloc_memdup(mem_ctx, (const void *)&ip.s_addr,
    136136                                            sizeof(ip.s_addr)))) {
    137137                return ERROR_DNS_NO_MEMORY;
     
    146146
    147147        return err;
     148}
     149
     150DNS_ERROR dns_create_aaaa_record(TALLOC_CTX *mem_ctx, const char *host,
     151                                 uint32_t ttl, const struct sockaddr_storage *pss,
     152                                 struct dns_rrec **prec)
     153{
     154#ifdef HAVE_IPV6
     155        uint8_t *data;
     156        DNS_ERROR err;
     157        struct in6_addr ip6;
     158
     159        if (pss->ss_family != AF_INET6) {
     160                return ERROR_DNS_INVALID_PARAMETER;
     161        }
     162
     163        ip6 = ((const struct sockaddr_in6 *)pss)->sin6_addr;
     164        if (!(data = (uint8_t *)talloc_memdup(mem_ctx, (const void *)&ip6.s6_addr,
     165                                            sizeof(ip6.s6_addr)))) {
     166                return ERROR_DNS_NO_MEMORY;
     167        }
     168
     169        err = dns_create_rrec(mem_ctx, host, QTYPE_AAAA, DNS_CLASS_IN, ttl,
     170                              sizeof(ip6.s6_addr), data, prec);
     171
     172        if (!ERR_DNS_IS_OK(err)) {
     173                TALLOC_FREE(data);
     174        }
     175
     176        return err;
     177#else
     178        return ERROR_DNS_INVALID_PARAMETER;
     179#endif
    148180}
    149181
     
    154186{
    155187        if (ss != NULL) {
    156                 return dns_create_a_record(mem_ctx, name, 0, ss, prec);
     188                switch (ss->ss_family) {
     189                case AF_INET:
     190                        return dns_create_a_record(mem_ctx, name, 0, ss, prec);
     191#ifdef HAVE_IPV6
     192                case AF_INET6:
     193                        return dns_create_aaaa_record(mem_ctx, name, 0, ss, prec);
     194#endif
     195                default:
     196                        return ERROR_DNS_INVALID_PARAMETER;
     197                }
    157198        }
    158199
     
    162203
    163204DNS_ERROR dns_create_name_not_in_use_record(TALLOC_CTX *mem_ctx,
    164                                             const char *name, uint32 type,
     205                                            const char *name, uint32_t type,
    165206                                            struct dns_rrec **prec)
    166207{
     
    170211
    171212DNS_ERROR dns_create_delete_record(TALLOC_CTX *mem_ctx, const char *name,
    172                                    uint16 type, uint16 r_class,
     213                                   uint16_t type, uint16_t r_class,
    173214                                   struct dns_rrec **prec)
    174215{
     
    178219DNS_ERROR dns_create_tkey_record(TALLOC_CTX *mem_ctx, const char *keyname,
    179220                                 const char *algorithm_name, time_t inception,
    180                                  time_t expiration, uint16 mode, uint16 error,
    181                                  uint16 key_length, const uint8 *key,
     221                                 time_t expiration, uint16_t mode, uint16_t error,
     222                                 uint16_t key_length, const uint8_t *key,
    182223                                 struct dns_rrec **prec)
    183224{
     
    218259                                     struct dns_tkey_record **ptkey)
    219260{
    220         struct dns_tkey_record *tkey = NULL;
     261        struct dns_tkey_record *tkey;
    221262        struct dns_buffer buf;
    222         uint32 tmp_inception, tmp_expiration;
     263        uint32_t tmp_inception, tmp_expiration;
    223264       
    224265        if (!(tkey = talloc(mem_ctx, struct dns_tkey_record))) {
     
    241282
    242283        if (tkey->key_length) {
    243                 if (!(tkey->key = TALLOC_ARRAY(tkey, uint8, tkey->key_length))) {
     284                if (!(tkey->key = talloc_array(tkey, uint8_t, tkey->key_length))) {
    244285                        buf.error = ERROR_DNS_NO_MEMORY;
    245286                        goto error;
     
    265306DNS_ERROR dns_create_tsig_record(TALLOC_CTX *mem_ctx, const char *keyname,
    266307                                 const char *algorithm_name,
    267                                  time_t time_signed, uint16 fudge,
    268                                  uint16 mac_length, const uint8 *mac,
    269                                  uint16 original_id, uint16 error,
     308                                 time_t time_signed, uint16_t fudge,
     309                                 uint16_t mac_length, const uint8_t *mac,
     310                                 uint16_t original_id, uint16_t error,
    270311                                 struct dns_rrec **prec)
    271312{
     
    305346
    306347DNS_ERROR dns_add_rrec(TALLOC_CTX *mem_ctx, struct dns_rrec *rec,
    307                        uint16 *num_records, struct dns_rrec ***records)
     348                       uint16_t *num_records, struct dns_rrec ***records)
    308349{
    309350        struct dns_rrec **new_records;
    310351
    311         if (!(new_records = TALLOC_REALLOC_ARRAY(mem_ctx, *records,
     352        if (!(new_records = talloc_realloc(mem_ctx, *records,
    312353                                                 struct dns_rrec *,
    313354                                                 (*num_records)+1))) {
     
    335376        struct dns_rrec *rec = NULL;
    336377        DNS_ERROR err;
    337         uint16 i;
     378        uint16_t i;
    338379
    339380        err = dns_create_update(mem_ctx, zone, &req);
    340         if (!ERR_DNS_IS_OK(err)) goto error;
     381        if (!ERR_DNS_IS_OK(err)) return err;
    341382
    342383        err = dns_create_name_not_in_use_record(req, host, QTYPE_CNAME, &rec);
     
    405446
    406447        for ( i=0; i<num_addrs; i++ ) {
    407                 err = dns_create_a_record(req, hostname, 3600, &ss_addrs[i], &rec);
     448
     449                switch(ss_addrs[i].ss_family) {
     450                case AF_INET:
     451                        err = dns_create_a_record(req, hostname, 3600, &ss_addrs[i], &rec);
     452                        break;
     453#ifdef HAVE_IPV6
     454                case AF_INET6:
     455                        err = dns_create_aaaa_record(req, hostname, 3600, &ss_addrs[i], &rec);
     456                        break;
     457#endif
     458                default:
     459                        continue;
     460                }
    408461                if (!ERR_DNS_IS_OK(err))
    409462                        goto error;
  • vendor/current/lib/addns/dnssock.c

    r740 r988  
    2828#include <unistd.h>
    2929#include "system/select.h"
     30#include "../lib/util/debug.h"
    3031
    3132static int destroy_dns_connection(struct dns_connection *conn)
     
    4142                               struct dns_connection **result )
    4243{
    43         uint32_t ulAddress;
    44         struct hostent *pHost;
    45         struct sockaddr_in s_in;
     44        struct addrinfo hints;
     45        struct addrinfo *ai_result = NULL;
     46        struct addrinfo *rp;
    4647        struct dns_connection *conn;
    47         int res;
     48        int ret;
     49        char service[16];
     50
     51        snprintf(service, sizeof(service), "%d", DNS_TCP_PORT);
    4852
    4953        if (!(conn = talloc(mem_ctx, struct dns_connection))) {
     
    5155        }
    5256
    53         if ( (ulAddress = inet_addr( nameserver )) == INADDR_NONE ) {
    54                 if ( (pHost = gethostbyname( nameserver )) == NULL ) {
    55                         TALLOC_FREE(conn);
    56                         return ERROR_DNS_INVALID_NAME_SERVER;
    57                 }
    58                 memcpy( &ulAddress, pHost->h_addr, pHost->h_length );
    59         }
    60 
    61         conn->s = socket( PF_INET, SOCK_STREAM, 0 );
    62         if (conn->s == -1) {
     57        memset(&hints, 0, sizeof(struct addrinfo));
     58        hints.ai_family = AF_UNSPEC;
     59        hints.ai_socktype = SOCK_STREAM;
     60        hints.ai_flags = 0;
     61        hints.ai_protocol = IPPROTO_TCP;
     62
     63        ret = getaddrinfo(nameserver, service, &hints, &ai_result);
     64        if (ret != 0) {
     65                DEBUG(1,("dns_tcp_open: getaddrinfo: %s\n", gai_strerror(ret)));
     66                TALLOC_FREE(conn);
     67                return ERROR_DNS_INVALID_NAME_SERVER;
     68        }
     69
     70        for (rp = ai_result; rp != NULL; rp = rp->ai_next) {
     71                conn->s = socket(rp->ai_family,
     72                                rp->ai_socktype,
     73                                rp->ai_protocol);
     74                if (conn->s == -1) {
     75                        continue;
     76                }
     77                do {
     78                        ret = connect(conn->s, rp->ai_addr, rp->ai_addrlen);
     79                } while ((ret == -1) && (errno == EINTR));
     80                if (ret != -1) {
     81                        /* Successful connect */
     82                        break;
     83                }
     84                close(conn->s);
     85        }
     86
     87        freeaddrinfo(ai_result);
     88
     89        /* Failed to connect with any address */
     90        if (rp == NULL) {
    6391                TALLOC_FREE(conn);
    6492                return ERROR_DNS_CONNECTION_FAILED;
     
    6795        talloc_set_destructor(conn, destroy_dns_connection);
    6896
    69         s_in.sin_family = AF_INET;
    70         s_in.sin_addr.s_addr = ulAddress;
    71         s_in.sin_port = htons( DNS_TCP_PORT );
    72 
    73         res = connect(conn->s, (struct sockaddr*)&s_in, sizeof( s_in ));
    74         if (res == -1) {
    75                 TALLOC_FREE(conn);
    76                 return ERROR_DNS_CONNECTION_FAILED;
    77         }
    78 
    7997        conn->hType = DNS_TCP;
    80 
    8198        *result = conn;
    8299        return ERROR_DNS_SUCCESS;
     
    84101
    85102/********************************************************************
    86 ********************************************************************/
     103 * ********************************************************************/
    87104
    88105static DNS_ERROR dns_udp_open( const char *nameserver,
     
    90107                               struct dns_connection **result )
    91108{
    92         unsigned long ulAddress;
    93         struct hostent *pHost;
    94         struct sockaddr_in RecvAddr;
     109        struct addrinfo hints;
     110        struct addrinfo *ai_result = NULL;
     111        struct addrinfo *rp;
     112        struct sockaddr_storage RecvAddr;
    95113        struct dns_connection *conn;
     114        int ret;
     115        socklen_t RecvAddrLen;
     116        char service[16];
     117
     118        snprintf(service, sizeof(service), "%d", DNS_UDP_PORT);
    96119
    97120        if (!(conn = talloc(NULL, struct dns_connection))) {
     
    99122        }
    100123
    101         if ( (ulAddress = inet_addr( nameserver )) == INADDR_NONE ) {
    102                 if ( (pHost = gethostbyname( nameserver )) == NULL ) {
    103                         TALLOC_FREE(conn);
    104                         return ERROR_DNS_INVALID_NAME_SERVER;
    105                 }
    106                 memcpy( &ulAddress, pHost->h_addr, pHost->h_length );
    107         }
    108 
    109         /* Create a socket for sending data */
    110 
    111         conn->s = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
    112         if (conn->s == -1) {
     124        memset(&hints, 0, sizeof(struct addrinfo));
     125        hints.ai_family = AF_UNSPEC;
     126        hints.ai_socktype = SOCK_DGRAM;
     127        hints.ai_flags = 0;
     128        hints.ai_protocol = IPPROTO_UDP;
     129
     130        ret = getaddrinfo(nameserver, service, &hints, &ai_result);
     131        if (ret != 0) {
     132                DEBUG(1,("dns_ucp_open:getaddrinfo: %s\n", gai_strerror(ret)));
     133                TALLOC_FREE(conn);
     134                return ERROR_DNS_INVALID_NAME_SERVER;
     135        }
     136
     137        for (rp = ai_result; rp != NULL; rp = rp->ai_next) {
     138                conn->s = socket(rp->ai_family,
     139                                rp->ai_socktype,
     140                                rp->ai_protocol);
     141                if (conn->s == -1) {
     142                        continue;
     143                }
     144                ret = connect(conn->s, rp->ai_addr, rp->ai_addrlen);
     145                if (ret != -1) {
     146                        /* Successful connect */
     147                        break;
     148                }
     149                close(conn->s);
     150        }
     151
     152        freeaddrinfo(ai_result);
     153
     154        /* Failed to connect with any address */
     155        if (rp == NULL) {
    113156                TALLOC_FREE(conn);
    114157                return ERROR_DNS_CONNECTION_FAILED;
     
    118161
    119162        /* Set up the RecvAddr structure with the IP address of
    120            the receiver (in this example case "123.456.789.1")
    121            and the specified port number. */
    122 
    123         ZERO_STRUCT(RecvAddr);
    124         RecvAddr.sin_family = AF_INET;
    125         RecvAddr.sin_port = htons( DNS_UDP_PORT );
    126         RecvAddr.sin_addr.s_addr = ulAddress;
     163           the receiver and the specified port number. */
     164
     165        RecvAddrLen = sizeof(RecvAddr);
     166        if (getpeername(conn->s,
     167                        (struct sockaddr *)&RecvAddr,
     168                        &RecvAddrLen) == -1) {
     169                TALLOC_FREE(conn);
     170                return ERROR_DNS_CONNECTION_FAILED;
     171        }
    127172
    128173        conn->hType = DNS_UDP;
    129         memcpy( &conn->RecvAddr, &RecvAddr, sizeof( struct sockaddr_in ) );
     174        memcpy(&conn->RecvAddr, &RecvAddr, sizeof(struct sockaddr_storage));
    130175
    131176        *result = conn;
     
    136181********************************************************************/
    137182
    138 DNS_ERROR dns_open_connection( const char *nameserver, int32 dwType,
     183DNS_ERROR dns_open_connection( const char *nameserver, int32_t dwType,
    139184                    TALLOC_CTX *mem_ctx,
    140185                    struct dns_connection **conn )
     
    150195}
    151196
    152 static DNS_ERROR write_all(int fd, uint8 *data, size_t len)
     197static DNS_ERROR write_all(int fd, uint8_t *data, size_t len)
    153198{
    154199        size_t total = 0;
     
    156201        while (total < len) {
    157202
    158                 ssize_t ret = write(fd, data + total, len - total);
     203                ssize_t ret;
     204
     205                do {
     206                        ret = write(fd, data + total, len - total);
     207                } while ((ret == -1) && (errno == EINTR));
    159208
    160209                if (ret <= 0) {
     
    174223                              const struct dns_buffer *buf)
    175224{
    176         uint16 len = htons(buf->offset);
     225        uint16_t len = htons(buf->offset);
    177226        DNS_ERROR err;
    178227
    179         err = write_all(conn->s, (uint8 *)&len, sizeof(len));
     228        err = write_all(conn->s, (uint8_t *)&len, sizeof(len));
    180229        if (!ERR_DNS_IS_OK(err)) return err;
    181230
     
    188237        ssize_t ret;
    189238
    190         ret = sendto(conn->s, buf->data, buf->offset, 0,
     239        do {
     240                ret = sendto(conn->s, buf->data, buf->offset, 0,
    191241                     (struct sockaddr *)&conn->RecvAddr,
    192242                     sizeof(conn->RecvAddr));
     243        } while ((ret == -1) && (errno == EINTR));
    193244
    194245        if (ret != buf->offset) {
     
    212263}
    213264
    214 static DNS_ERROR read_all(int fd, uint8 *data, size_t len)
     265static DNS_ERROR read_all(int fd, uint8_t *data, size_t len)
    215266{
    216267        size_t total = 0;
     
    226277
    227278                fd_ready = poll(&pfd, 1, 10000);
     279                if (fd_ready == -1) {
     280                        if (errno == EINTR) {
     281                                continue;
     282                        }
     283                        return ERROR_DNS_SOCKET_ERROR;
     284                }
    228285                if ( fd_ready == 0 ) {
    229286                        /* read timeout */
     
    231288                }
    232289
    233                 ret = read(fd, data + total, len - total);
     290                do {
     291                        ret = read(fd, data + total, len - total);
     292                } while ((ret == -1) && (errno == EINTR));
     293
    234294                if (ret <= 0) {
    235295                        /* EOF or error */
     
    249309        struct dns_buffer *buf;
    250310        DNS_ERROR err;
    251         uint16 len;
    252 
    253         if (!(buf = TALLOC_ZERO_P(mem_ctx, struct dns_buffer))) {
    254                 return ERROR_DNS_NO_MEMORY;
    255         }
    256 
    257         err = read_all(conn->s, (uint8 *)&len, sizeof(len));
     311        uint16_t len;
     312
     313        if (!(buf = talloc_zero(mem_ctx, struct dns_buffer))) {
     314                return ERROR_DNS_NO_MEMORY;
     315        }
     316
     317        err = read_all(conn->s, (uint8_t *)&len, sizeof(len));
    258318        if (!ERR_DNS_IS_OK(err)) {
    259319                return err;
     
    262322        buf->size = ntohs(len);
    263323
    264         if (buf->size) {
    265                 if (!(buf->data = TALLOC_ARRAY(buf, uint8, buf->size))) {
    266                         TALLOC_FREE(buf);
    267                         return ERROR_DNS_NO_MEMORY;
    268                 }
    269         } else {
    270                 buf->data = NULL;
    271         }
    272 
    273         err = read_all(conn->s, buf->data, buf->size);
     324        if (buf->size == 0) {
     325                *presult = buf;
     326                return ERROR_DNS_SUCCESS;
     327        }
     328
     329        if (!(buf->data = talloc_array(buf, uint8_t, buf->size))) {
     330                TALLOC_FREE(buf);
     331                return ERROR_DNS_NO_MEMORY;
     332        }
     333
     334        err = read_all(conn->s, buf->data, talloc_get_size(buf->data));
    274335        if (!ERR_DNS_IS_OK(err)) {
    275336                TALLOC_FREE(buf);
     
    288349        ssize_t received;
    289350
    290         if (!(buf = TALLOC_ZERO_P(mem_ctx, struct dns_buffer))) {
     351        if (!(buf = talloc_zero(mem_ctx, struct dns_buffer))) {
    291352                return ERROR_DNS_NO_MEMORY;
    292353        }
     
    296357         */
    297358
    298         if (!(buf->data = TALLOC_ARRAY(buf, uint8, 512))) {
     359        if (!(buf->data = talloc_array(buf, uint8_t, 512))) {
    299360                TALLOC_FREE(buf);
    300361                return ERROR_DNS_NO_MEMORY;
    301362        }
    302363
    303         received = recv(conn->s, (void *)buf->data, 512, 0);
     364        do {
     365                received = recv(conn->s, (void *)buf->data, 512, 0);
     366        } while ((received == -1) && (errno == EINTR));
    304367
    305368        if (received == -1) {
     
    341404        DNS_ERROR err;
    342405
    343         err = dns_marshall_request(conn, req, &buf);
     406        err = dns_marshall_request(mem_ctx, req, &buf);
    344407        if (!ERR_DNS_IS_OK(err)) goto error;
    345408
  • vendor/current/lib/addns/dnsutils.c

    r740 r988  
    2323*/
    2424
     25#include "includes.h"
     26#include "librpc/ndr/libndr.h"
     27#include "librpc/gen_ndr/ndr_misc.h"
     28
    2529#include "dns.h"
    2630#include <ctype.h>
     31
    2732
    2833static DNS_ERROR LabelList( TALLOC_CTX *mem_ctx,
     
    5459        }
    5560
    56         if (!(result = TALLOC_ZERO_P(mem_ctx, struct dns_domain_label))) {
     61        if (!(result = talloc_zero(mem_ctx, struct dns_domain_label))) {
    5762                return ERROR_DNS_NO_MEMORY;
    5863        }
     
    134139#if defined(WITH_DNS_UPDATES)
    135140
    136         uuid_t uuid;
     141        struct GUID guid;
    137142
    138         /*
    139          * uuid_unparse gives 36 bytes plus '\0'
    140          */
    141         if (!(result = TALLOC_ARRAY(mem_ctx, char, 37))) {
    142                 return NULL;
    143         }
    144 
    145         uuid_generate( uuid );
    146         uuid_unparse( uuid, result );
     143        guid = GUID_random();
     144        result = GUID_string(mem_ctx, &guid);
    147145
    148146#endif
  • vendor/current/lib/addns/wscript_build

    r740 r988  
    22
    33bld.SAMBA_LIBRARY('addns',
    4                    source='dnsrecord.c dnsutils.c dnssock.c dnsgss.c dnsmarshall.c error.c',
    5                    public_deps='talloc krb5 k5crypto com_err gssapi gssapi_krb5 uuid',
     4                   source='dnsquery.c dnsrecord.c dnsutils.c dnssock.c dnsgss.c dnsmarshall.c error.c',
     5                   public_deps='samba-util gssapi ndr resolv',
    66                   private_library=True,
    77                   vars=locals())
Note: See TracChangeset for help on using the changeset viewer.