Created attachment 9082 [details] patch files in ZIP format (diff -u) for above bug report Hello All, This patch for file 'dnsgss.c' in directory 'samba-4.0.7/lib/addns' corrects all of the issues if statements so that they correspond with standards coding which are defined in README.Coding in the 'samba-4.0.7' directory. The patch file is below: --- dnsgss.c.orig 2013-07-24 18:51:51.839545874 -0700 +++ dnsgss.c 2013-07-24 18:56:45.133550695 -0700 @@ -34,14 +34,14 @@ #ifndef HAVE_STRUPR static int strupr( char *szDomainName ) { - if ( !szDomainName ) { + if (!szDomainName) { return ( 0 ); } - while ( *szDomainName != '\0' ) { + while (*szDomainName != '\0') { *szDomainName = toupper( *szDomainName ); szDomainName++; } - return ( 0 ); + return (0); } #endif @@ -56,7 +56,7 @@ OM_uint32 msg_ctx; msg_ctx = 0; - while ( 1 ) { + while (1) { maj_stat = gss_display_status( &min_stat, code, type, GSS_C_NULL_OID, &msg_ctx, &msg ); @@ -64,8 +64,9 @@ ( char * ) msg.value ); ( void ) gss_release_buffer( &min_stat, &msg ); - if ( !msg_ctx ) + if (!msg_ctx) { break; + } } } @@ -120,20 +121,24 @@ err = dns_create_query(mem_ctx, keyname, QTYPE_TKEY, DNS_CLASS_IN, &req); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } err = dns_create_tkey_record( req, keyname, "gss.microsoft.com", t, t + 86400, DNS_TKEY_MODE_GSSAPI, 0, output_desc.length, (uint8_t *)output_desc.value, &rec ); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } /* Windows 2000 DNS is broken and requires the TKEY payload in the Answer section instead of the Additional seciton like Windows 2003 */ - if ( srv_type == DNS_SRV_WIN2000 ) { + if (srv_type == DNS_SRV_WIN2000) { err = dns_add_rrec(req, rec, &req->num_answers, &req->answers); } else { @@ -141,13 +146,19 @@ &req->additionals); } - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } err = dns_marshall_request(req, req, &buf); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } err = dns_send(conn, buf); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } TALLOC_FREE(req); } @@ -168,10 +179,14 @@ uint16_t i; err = dns_receive(mem_ctx, conn, &buf); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } err = dns_unmarshall_request(buf, buf, &resp); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } /* * TODO: Compare id and keyname @@ -192,7 +207,9 @@ err = dns_unmarshall_tkey_record( mem_ctx, resp->answers[0], &tkey); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } input_desc.length = tkey->key_length; input_desc.value = talloc_move(mem_ctx, &tkey->key); @@ -202,7 +219,7 @@ TALLOC_FREE(buf); } - } while ( major == GSS_S_CONTINUE_NEEDED ); + } while (major == GSS_S_CONTINUE_NEEDED); /* If we arrive here, we have a valid security context */ @@ -239,7 +256,9 @@ } err = dns_open_connection( servername, DNS_TCP, mem_ctx, &conn ); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } if (!(upcaserealm = talloc_strdup(mem_ctx, target_realm))) { err = ERROR_DNS_NO_MEMORY; @@ -290,13 +309,19 @@ struct dns_rrec *rec; err = dns_marshall_update_request(req, req, &buf); - if (!ERR_DNS_IS_OK(err)) return err; + if (!ERR_DNS_IS_OK(err)) { + return err; + } err = dns_domain_name_from_string(buf, keyname, &key); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } err = dns_domain_name_from_string(buf, algorithmname, &algorithm); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } dns_marshall_domain_name(buf, key); dns_marshall_uint16(buf, DNS_CLASS_ANY); @@ -309,7 +334,9 @@ dns_marshall_uint16(buf, 0); /* other len */ err = buf->error; - if (!ERR_DNS_IS_OK(buf->error)) goto error; + if (!ERR_DNS_IS_OK(buf->error)) { + goto error; + } msg.value = (void *)buf->data; msg.length = buf->offset; @@ -330,7 +357,9 @@ fudge, mic.length, (uint8_t *)mic.value, req->id, 0, &rec); gss_release_buffer(&minor, &mic); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } err = dns_add_rrec(req, rec, &req->num_additionals, &req->additionals); This patch for file 'dnsmarshall.c' in directory 'samba-4.0.7/lib/addns' corrects all of the issues if statements so that they correspond with standards coding which are defined in README.Coding in the 'samba-4.0.7' directory. The patch file is below: --- dnsmarshall.c 2013-07-24 19:04:37.449547474 -0700 +++ dnsmarshall.c.orig 2013-07-24 19:07:29.231552947 -0700 @@ -50,9 +50,7 @@ void dns_marshall_buffer(struct dns_buffer *buf, const uint8_t *data, size_t len) { - if (!ERR_DNS_IS_OK(buf->error)) { - return; - } + if (!ERR_DNS_IS_OK(buf->error)) return; if (buf->offset + len < buf->offset) { /* @@ -110,9 +108,7 @@ void dns_unmarshall_buffer(struct dns_buffer *buf, uint8_t *data, size_t len) { - if (!(ERR_DNS_IS_OK(buf->error))) { - return; - } + if (!(ERR_DNS_IS_OK(buf->error))) return; if ((len > buf->size) || (buf->offset + len > buf->size)) { buf->error = ERROR_DNS_INVALID_MESSAGE; @@ -130,9 +126,7 @@ uint16_t n_val; dns_unmarshall_buffer(buf, (uint8_t *)&n_val, sizeof(n_val)); - if (!(ERR_DNS_IS_OK(buf->error))) { - return; - } + if (!(ERR_DNS_IS_OK(buf->error))) return; *val = ntohs(n_val); } @@ -142,9 +136,7 @@ uint32_t n_val; dns_unmarshall_buffer(buf, (uint8_t *)&n_val, sizeof(n_val)); - if (!(ERR_DNS_IS_OK(buf->error))) { - return; - } + if (!(ERR_DNS_IS_OK(buf->error))) return; *val = ntohl(n_val); } @@ -163,14 +155,10 @@ uint8_t len = label->len; dns_marshall_buffer(buf, (uint8_t *)&len, sizeof(len)); - if (!ERR_DNS_IS_OK(buf->error)) { - return; - } + if (!ERR_DNS_IS_OK(buf->error)) return; dns_marshall_buffer(buf, (uint8_t *)label->label, len); - if (!ERR_DNS_IS_OK(buf->error)) { - return; - } + if (!ERR_DNS_IS_OK(buf->error)) return; } dns_marshall_buffer(buf, (uint8_t *)&end_char, 1); @@ -184,9 +172,7 @@ struct dns_domain_label *label; uint8_t len; - if (!ERR_DNS_IS_OK(buf->error)) { - return; - } + if (!ERR_DNS_IS_OK(buf->error)) return; if (level > 128) { /* @@ -197,9 +183,7 @@ } dns_unmarshall_buffer(buf, &len, sizeof(len)); - if (!ERR_DNS_IS_OK(buf->error)) { - return; - } + if (!ERR_DNS_IS_OK(buf->error)) return; if (len == 0) { *plabel = NULL; @@ -215,9 +199,7 @@ uint8_t low; dns_unmarshall_buffer(buf, &low, sizeof(low)); - if (!ERR_DNS_IS_OK(buf->error)) { - return; - } + if (!ERR_DNS_IS_OK(buf->error)) return; new_buf = *buf; new_buf.offset = len & 0x3f; @@ -247,14 +229,10 @@ } dns_unmarshall_buffer(buf, (uint8_t *)label->label, len); - if (!ERR_DNS_IS_OK(buf->error)) { - goto error; - } + if (!ERR_DNS_IS_OK(buf->error)) goto error; dns_unmarshall_label(label, level+1, buf, &label->next); - if (!ERR_DNS_IS_OK(buf->error)) { - goto error; - } + if (!ERR_DNS_IS_OK(buf->error)) goto error; *plabel = label; return; @@ -270,9 +248,7 @@ { struct dns_domain_name *name; - if (!ERR_DNS_IS_OK(buf->error)) { - return; - } + if (!ERR_DNS_IS_OK(buf->error)) return; if (!(name = talloc_zero(mem_ctx, struct dns_domain_name))) { buf->error = ERROR_DNS_NO_MEMORY; @@ -303,9 +279,7 @@ { struct dns_question *q; - if (!(ERR_DNS_IS_OK(buf->error))) { - return; - } + if (!(ERR_DNS_IS_OK(buf->error))) return; if (!(q = talloc_zero(mem_ctx, struct dns_question))) { buf->error = ERROR_DNS_NO_MEMORY; @@ -316,9 +290,7 @@ dns_unmarshall_uint16(buf, &q->q_type); dns_unmarshall_uint16(buf, &q->q_class); - if (!(ERR_DNS_IS_OK(buf->error))) { - return; - } + if (!(ERR_DNS_IS_OK(buf->error))) return; *pq = q; } @@ -340,9 +312,7 @@ { struct dns_rrec *r; - if (!(ERR_DNS_IS_OK(buf->error))) { - return; - } + if (!(ERR_DNS_IS_OK(buf->error))) return; if (!(r = talloc_zero(mem_ctx, struct dns_rrec))) { buf->error = ERROR_DNS_NO_MEMORY; @@ -356,9 +326,7 @@ dns_unmarshall_uint16(buf, &r->data_length); r->data = NULL; - if (!(ERR_DNS_IS_OK(buf->error))) { - return; - } + if (!(ERR_DNS_IS_OK(buf->error))) return; if (r->data_length != 0) { if (!(r->data = talloc_zero_array(r, uint8_t, r->data_length))) { @@ -368,9 +336,7 @@ dns_unmarshall_buffer(buf, r->data, r->data_length); } - if (!(ERR_DNS_IS_OK(buf->error))) { - return; - } + if (!(ERR_DNS_IS_OK(buf->error))) return; *pr = r; } @@ -435,9 +401,7 @@ dns_unmarshall_uint16(buf, &req->num_auths); dns_unmarshall_uint16(buf, &req->num_additionals); - if (!ERR_DNS_IS_OK(buf->error)) { - goto error; - } + if (!ERR_DNS_IS_OK(buf->error)) goto error; err = ERROR_DNS_NO_MEMORY; This patch for file 'dnsmarshall.c' in directory 'samba-4.0.7/lib/addns' corrects all of the issues if statements so that they correspond with standards coding which are defined in README.Coding in the 'samba-4.0.7' directory. The patch file is below: --- dnsmarshall.c.orig 2013-07-24 19:07:29.231552947 -0700 +++ dnsmarshall.c 2013-07-25 08:05:04.568517831 -0700 @@ -50,7 +50,9 @@ void dns_marshall_buffer(struct dns_buffer *buf, const uint8_t *data, size_t len) { - if (!ERR_DNS_IS_OK(buf->error)) return; + if (!ERR_DNS_IS_OK(buf->error)) { + return; + } if (buf->offset + len < buf->offset) { /* @@ -108,7 +110,9 @@ void dns_unmarshall_buffer(struct dns_buffer *buf, uint8_t *data, size_t len) { - if (!(ERR_DNS_IS_OK(buf->error))) return; + if (!(ERR_DNS_IS_OK(buf->error))) { + return; + } if ((len > buf->size) || (buf->offset + len > buf->size)) { buf->error = ERROR_DNS_INVALID_MESSAGE; @@ -126,7 +130,9 @@ uint16_t n_val; dns_unmarshall_buffer(buf, (uint8_t *)&n_val, sizeof(n_val)); - if (!(ERR_DNS_IS_OK(buf->error))) return; + if (!(ERR_DNS_IS_OK(buf->error))) { + return; + } *val = ntohs(n_val); } @@ -136,7 +142,9 @@ uint32_t n_val; dns_unmarshall_buffer(buf, (uint8_t *)&n_val, sizeof(n_val)); - if (!(ERR_DNS_IS_OK(buf->error))) return; + if (!(ERR_DNS_IS_OK(buf->error))) { + return; + } *val = ntohl(n_val); } @@ -155,10 +163,14 @@ uint8_t len = label->len; dns_marshall_buffer(buf, (uint8_t *)&len, sizeof(len)); - if (!ERR_DNS_IS_OK(buf->error)) return; + if (!ERR_DNS_IS_OK(buf->error)) { + return; + } dns_marshall_buffer(buf, (uint8_t *)label->label, len); - if (!ERR_DNS_IS_OK(buf->error)) return; + if (!ERR_DNS_IS_OK(buf->error)) { + return; + } } dns_marshall_buffer(buf, (uint8_t *)&end_char, 1); @@ -172,7 +184,9 @@ struct dns_domain_label *label; uint8_t len; - if (!ERR_DNS_IS_OK(buf->error)) return; + if (!ERR_DNS_IS_OK(buf->error)) { + return; + } if (level > 128) { /* @@ -183,7 +197,9 @@ } dns_unmarshall_buffer(buf, &len, sizeof(len)); - if (!ERR_DNS_IS_OK(buf->error)) return; + if (!ERR_DNS_IS_OK(buf->error)) { + return; + } if (len == 0) { *plabel = NULL; @@ -199,7 +215,9 @@ uint8_t low; dns_unmarshall_buffer(buf, &low, sizeof(low)); - if (!ERR_DNS_IS_OK(buf->error)) return; + if (!ERR_DNS_IS_OK(buf->error)) { + return; + } new_buf = *buf; new_buf.offset = len & 0x3f; @@ -229,10 +247,14 @@ } dns_unmarshall_buffer(buf, (uint8_t *)label->label, len); - if (!ERR_DNS_IS_OK(buf->error)) goto error; + if (!ERR_DNS_IS_OK(buf->error)) { + goto error; + } dns_unmarshall_label(label, level+1, buf, &label->next); - if (!ERR_DNS_IS_OK(buf->error)) goto error; + if (!ERR_DNS_IS_OK(buf->error)) { + goto error; + } *plabel = label; return; @@ -248,7 +270,9 @@ { struct dns_domain_name *name; - if (!ERR_DNS_IS_OK(buf->error)) return; + if (!ERR_DNS_IS_OK(buf->error)) { + return; + } if (!(name = talloc_zero(mem_ctx, struct dns_domain_name))) { buf->error = ERROR_DNS_NO_MEMORY; @@ -279,7 +303,9 @@ { struct dns_question *q; - if (!(ERR_DNS_IS_OK(buf->error))) return; + if (!(ERR_DNS_IS_OK(buf->error))) { + return; + } if (!(q = talloc_zero(mem_ctx, struct dns_question))) { buf->error = ERROR_DNS_NO_MEMORY; @@ -290,7 +316,9 @@ dns_unmarshall_uint16(buf, &q->q_type); dns_unmarshall_uint16(buf, &q->q_class); - if (!(ERR_DNS_IS_OK(buf->error))) return; + if (!(ERR_DNS_IS_OK(buf->error))) { + return; + } *pq = q; } @@ -312,7 +340,9 @@ { struct dns_rrec *r; - if (!(ERR_DNS_IS_OK(buf->error))) return; + if (!(ERR_DNS_IS_OK(buf->error))) { + return; + } if (!(r = talloc_zero(mem_ctx, struct dns_rrec))) { buf->error = ERROR_DNS_NO_MEMORY; @@ -326,7 +356,9 @@ dns_unmarshall_uint16(buf, &r->data_length); r->data = NULL; - if (!(ERR_DNS_IS_OK(buf->error))) return; + if (!(ERR_DNS_IS_OK(buf->error))) { + return; + } if (r->data_length != 0) { if (!(r->data = talloc_zero_array(r, uint8_t, r->data_length))) { @@ -336,7 +368,9 @@ dns_unmarshall_buffer(buf, r->data, r->data_length); } - if (!(ERR_DNS_IS_OK(buf->error))) return; + if (!(ERR_DNS_IS_OK(buf->error))) { + return; + } *pr = r; } @@ -401,7 +435,9 @@ dns_unmarshall_uint16(buf, &req->num_auths); dns_unmarshall_uint16(buf, &req->num_additionals); - if (!ERR_DNS_IS_OK(buf->error)) goto error; + if (!ERR_DNS_IS_OK(buf->error)) { + goto error; + } err = ERROR_DNS_NO_MEMORY; This patch for file 'dnsquery.c' in directory 'samba-4.0.7/lib/addns' corrects all of the issues if statements so that they correspond with standards coding which are defined in README.Coding in the 'samba-4.0.7' directory. The patch file is below: --- dnsquery.c.orig 2013-07-24 19:09:10.677549174 -0700 +++ dnsquery.c 2013-07-24 19:15:45.984545711 -0700 @@ -85,13 +85,14 @@ ZERO_STRUCTP( q ); - if ( !start || !end || !q || !*ptr) + if (!start || !end || !q || !*ptr) { return false; + } /* See RFC 1035 for details. If this fails, then return. */ namelen = dn_expand( start, end, p, hostname, sizeof(hostname) ); - if ( namelen < 0 ) { + if (namelen < 0) { return false; } p += namelen; @@ -99,8 +100,9 @@ /* check that we have space remaining */ - if ( PTR_DIFF(p+4, end) > 0 ) + if (PTR_DIFF(p+4, end) > 0) { return false; + } q->type = RSVAL( p, 0 ); q->in_class = RSVAL( p, 2 ); @@ -121,14 +123,15 @@ char hostname[MAX_DNS_NAME_LENGTH]; int namelen; - if ( !start || !end || !rr || !*ptr) + if (!start || !end || !rr || !*ptr) { return -1; + } ZERO_STRUCTP( rr ); /* pull the name from the answer */ namelen = dn_expand( start, end, p, hostname, sizeof(hostname) ); - if ( namelen < 0 ) { + if (namelen < 0) { return -1; } p += namelen; @@ -136,8 +139,9 @@ /* check that we have space remaining */ - if ( PTR_DIFF(p+10, end) > 0 ) + if (PTR_DIFF(p+10, end) > 0) { return false; + } /* pull some values and then skip onto the string */ @@ -150,9 +154,8 @@ /* sanity check the available space */ - if ( PTR_DIFF(p+rr->rdatalen, end ) > 0 ) { + if (PTR_DIFF(p+rr->rdatalen, end ) > 0) { return false; - } /* save a point to the rdata for this section */ @@ -176,18 +179,19 @@ char dcname[MAX_DNS_NAME_LENGTH]; int namelen; - if ( !start || !end || !srv || !*ptr) + if (!start || !end || !srv || !*ptr) { return -1; + } /* Parse the RR entry. Coming out of the this, ptr is at the beginning of the next record */ - if ( !ads_dns_parse_rr( ctx, start, end, ptr, &rr ) ) { + if (!ads_dns_parse_rr( ctx, start, end, ptr, &rr )) { DEBUG(1,("ads_dns_parse_rr_srv: Failed to parse RR record\n")); return false; } - if ( rr.type != T_SRV ) { + if (rr.type != T_SRV) { DEBUG(1,("ads_dns_parse_rr_srv: Bad answer type (%d)\n", rr.type)); return false; @@ -202,7 +206,7 @@ p += 6; namelen = dn_expand( start, end, p, dcname, sizeof(dcname) ); - if ( namelen < 0 ) { + if (namelen < 0) { DEBUG(1,("ads_dns_parse_rr_srv: Failed to uncompress name!\n")); return false; } @@ -229,18 +233,19 @@ char nsname[MAX_DNS_NAME_LENGTH]; int namelen; - if ( !start || !end || !nsrec || !*ptr) + if (!start || !end || !nsrec || !*ptr) { return -1; + } /* Parse the RR entry. Coming out of the this, ptr is at the beginning of the next record */ - if ( !ads_dns_parse_rr( ctx, start, end, ptr, &rr ) ) { + if (!ads_dns_parse_rr( ctx, start, end, ptr, &rr )) { DEBUG(1,("ads_dns_parse_rr_ns: Failed to parse RR record\n")); return false; } - if ( rr.type != T_NS ) { + if (rr.type != T_NS) { DEBUG(1,("ads_dns_parse_rr_ns: Bad answer type (%d)\n", rr.type)); return false; @@ -251,7 +256,7 @@ /* ame server hostname */ namelen = dn_expand( start, end, p, nsname, sizeof(nsname) ); - if ( namelen < 0 ) { + if (namelen < 0) { DEBUG(1,("ads_dns_parse_rr_ns: Failed to uncompress name!\n")); return false; } @@ -266,21 +271,25 @@ static int dnssrvcmp( struct dns_rr_srv *a, struct dns_rr_srv *b ) { - if ( a->priority == b->priority ) { + if (a->priority == b->priority) { /* randomize entries with an equal weight and priority */ - if ( a->weight == b->weight ) + if (a->weight == b->weight) { return 0; + } /* higher weights should be sorted lower */ - if ( a->weight > b->weight ) + if (a->weight > b->weight) { return -1; - else + } + else { return 1; + } } - if ( a->priority < b->priority ) + if (a->priority < b->priority) { return -1; + } return 1; } @@ -305,16 +314,17 @@ /* Protect against large clock changes */ - if ( last_dns_check > now ) + if (last_dns_check > now) { last_dns_check = 0; + } /* IF we had a DNS timeout or a bad server and we are still in the 30 second cache window, just return the previous status and save the network timeout. */ - if ( (NT_STATUS_EQUAL(last_dns_status,NT_STATUS_IO_TIMEOUT) || + if ((NT_STATUS_EQUAL(last_dns_status,NT_STATUS_IO_TIMEOUT) || NT_STATUS_EQUAL(last_dns_status,NT_STATUS_CONNECTION_REFUSED)) && - (last_dns_check+DNS_FAILED_WAITTIME) > now ) + (last_dns_check+DNS_FAILED_WAITTIME) > now) { DEBUG(10,("dns_send_req: last dns check returning cached status (%s)\n", nt_errstr(last_dns_status) )); @@ -323,8 +333,9 @@ /* Send the Query */ do { - if ( buffer ) + if (buffer) { TALLOC_FREE( buffer ); + } buf_len = resp_len * sizeof(uint8_t); @@ -404,7 +415,7 @@ int idx = 0; NTSTATUS status; - if ( !ctx || !name || !dclist ) { + if (!ctx || !name || !dclist) { return NT_STATUS_INVALID_PARAMETER; } @@ -418,7 +429,7 @@ of large replies */ status = dns_send_req( ctx, name, T_SRV, &buffer, &resp_len ); - if ( !NT_STATUS_IS_OK(status) ) { + if (!NT_STATUS_IS_OK(status)) { DEBUG(3,("ads_dns_lookup_srv: Failed to send DNS query (%s)\n", nt_errstr(status))); return status; @@ -527,7 +538,7 @@ } for ( i=0; i<idx; i++ ) { - if ( strcmp( rr.hostname, dcs[i].hostname ) == 0 ) { + if (strcmp( rr.hostname, dcs[i].hostname ) == 0) { int num_ips = dcs[i].num_ips; struct sockaddr_storage *tmp_ss_s; This patch for file 'dnssock.c' in directory 'samba-4.0.7/lib/addns' corrects all of the issues if statements so that they correspond with standards coding which are defined in README.Coding in the 'samba-4.0.7' directory. The patch file is below: --- dnssock.c.orig 2013-07-25 15:08:37.195502313 -0700 +++ dnssock.c 2013-07-25 15:16:53.860485241 -0700 @@ -177,7 +177,9 @@ DNS_ERROR err; err = write_all(conn->s, (uint8_t *)&len, sizeof(len)); - if (!ERR_DNS_IS_OK(err)) return err; + if (!ERR_DNS_IS_OK(err)) { + return err; + } return write_all(conn->s, buf->data, buf->offset); } @@ -225,7 +227,7 @@ pfd.events = POLLIN|POLLHUP; fd_ready = poll(&pfd, 1, 10000); - if ( fd_ready == 0 ) { + if (fd_ready == 0) { /* read timeout */ return ERROR_DNS_SOCKET_ERROR; } @@ -341,14 +343,20 @@ DNS_ERROR err; err = dns_marshall_request(mem_ctx, req, &buf); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } err = dns_send(conn, buf); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } TALLOC_FREE(buf); err = dns_receive(mem_ctx, conn, &buf); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } err = dns_unmarshall_request(mem_ctx, buf, resp); @@ -368,7 +376,9 @@ err = dns_transaction(mem_ctx, conn, dns_update2request(up_req), &resp); - if (!ERR_DNS_IS_OK(err)) return err; + if (!ERR_DNS_IS_OK(err)) { + return err; + } *up_resp = dns_request2update(resp); return ERROR_DNS_SUCCESS; This patch for file 'dnsrecord.c' in directory 'samba-4.0.7/lib/addns' corrects all of the issues if statements so that they correspond with standards coding which are defined in README.Coding in the 'samba-4.0.7' directory. The patch file is below: --- dnsrecord.c.orig 2013-07-25 15:21:03.023503359 -0700 +++ dnsrecord.c 2013-07-25 15:25:11.175502307 -0700 @@ -230,7 +230,9 @@ } err = dns_domain_name_from_string(buf, algorithm_name, &algorithm); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } dns_marshall_domain_name(buf, algorithm); dns_marshall_uint32(buf, inception); @@ -277,7 +279,9 @@ dns_unmarshall_uint16(&buf, &tkey->error); dns_unmarshall_uint16(&buf, &tkey->key_length); - if (!ERR_DNS_IS_OK(buf.error)) goto error; + if (!ERR_DNS_IS_OK(buf.error)) { + goto error; + } if (tkey->key_length) { if (!(tkey->key = talloc_array(tkey, uint8_t, tkey->key_length))) { @@ -289,7 +293,9 @@ } dns_unmarshall_buffer(&buf, tkey->key, tkey->key_length); - if (!ERR_DNS_IS_OK(buf.error)) goto error; + if (!ERR_DNS_IS_OK(buf.error)) { + goto error; + } tkey->inception = (time_t)tmp_inception; tkey->expiration = (time_t)tmp_expiration; @@ -318,7 +324,9 @@ } err = dns_domain_name_from_string(buf, algorithm_name, &algorithm); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } dns_marshall_domain_name(buf, algorithm); dns_marshall_uint16(buf, 0); /* time prefix */ @@ -377,21 +385,31 @@ uint16_t i; err = dns_create_update(mem_ctx, zone, &req); - if (!ERR_DNS_IS_OK(err)) return err; + if (!ERR_DNS_IS_OK(err)) { + return err; + } err = dns_create_name_not_in_use_record(req, host, QTYPE_CNAME, &rec); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } err = dns_add_rrec(req, rec, &req->num_preqs, &req->preqs); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } for (i=0; i<num_ips; i++) { err = dns_create_name_in_use_record(req, host, &sslist[i], &rec); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } err = dns_add_rrec(req, rec, &req->num_preqs, &req->preqs); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } } *preq = req; @@ -415,7 +433,9 @@ size_t i; err = dns_create_update(mem_ctx, domainname, &req); - if (!ERR_DNS_IS_OK(err)) return err; + if (!ERR_DNS_IS_OK(err)) { + return err; + } /* * Use the same prereq as WinXP -- No CNAME records for this host. @@ -423,10 +443,14 @@ err = dns_create_rrec(req, hostname, QTYPE_CNAME, DNS_CLASS_NONE, 0, 0, NULL, &rec); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } err = dns_add_rrec(req, rec, &req->num_preqs, &req->preqs); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } /* * Delete any existing A records @@ -434,10 +458,14 @@ err = dns_create_delete_record(req, hostname, QTYPE_A, DNS_CLASS_ANY, &rec); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } err = dns_add_rrec(req, rec, &req->num_updates, &req->updates); - if (!ERR_DNS_IS_OK(err)) goto error; + if (!ERR_DNS_IS_OK(err)) { + goto error; + } /* * .. and add our IPs @@ -457,12 +485,14 @@ default: continue; } - if (!ERR_DNS_IS_OK(err)) + if (!ERR_DNS_IS_OK(err)) { goto error; + } err = dns_add_rrec(req, rec, &req->num_updates, &req->updates); - if (!ERR_DNS_IS_OK(err)) + if (!ERR_DNS_IS_OK(err)) { goto error; + } } *preq = req; I am attaching all the patch files to this bug report as a single zip file. A 'make' results in a clean compile of the above patch files. Bill Parker (wp02855 at gmail dot com)
Is there any chance you could install git, and produce these patches with git commit and git format-patch? That way you can set the author and commit message, and we can simply import the patches. It is a pain to set up the first time, but makes it much easier for us to just accept your patches later.