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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/libsmb/nmblib.c

    r740 r988  
    6969                res->ttl ) );
    7070
    71         if( res->rdlength == 0 || res->rdata == NULL )
     71        if (res->rdlength == 0) {
    7272                return;
     73        }
    7374
    7475        for (i = 0; i < res->rdlength; i+= MAX_NETBIOSNAME_LEN) {
     
    289290******************************************************************/
    290291
    291 static int put_nmb_name(char *buf,int offset,struct nmb_name *name)
     292static int put_nmb_name(char *buf, size_t buflen, int offset,struct nmb_name *name)
    292293{
    293294        int ret,m;
     
    303304
    304305        if (buf) {
     306                if (offset >= buflen) {
     307                        return 0;
     308                }
    305309                buf[offset] = 0x20;
    306310        }
     
    310314        for (m=0;m<MAX_NETBIOSNAME_LEN;m++) {
    311315                if (buf) {
     316                        if (offset+2+2*m >= buflen) {
     317                                return 0;
     318                        }
    312319                        buf[offset+1+2*m] = 'A' + ((buf1[m]>>4)&0xF);
    313320                        buf[offset+2+2*m] = 'A' + (buf1[m]&0xF);
     
    317324
    318325        if (buf) {
     326                if (offset >= buflen) {
     327                        return 0;
     328                }
    319329                buf[offset] = 0;
    320330        }
     
    322332        if (name->scope[0]) {
    323333                /* XXXX this scope handling needs testing */
    324                 ret += strlen(name->scope) + 1;
     334                size_t scopenamelen = strlen(name->scope) + 1;
     335                ret += scopenamelen;
    325336                if (buf) {
    326                         safe_strcpy(&buf[offset+1],name->scope,
    327                                         sizeof(name->scope));
     337                        if (offset+1+scopenamelen >= buflen) {
     338                                return 0;
     339                        }
     340                        strlcpy(&buf[offset+1],name->scope,
     341                                        buflen - (offset+1));
    328342
    329343                        p = &buf[offset+1];
     
    331345                                buf[offset] = PTR_DIFF(p,&buf[offset+1]);
    332346                                offset += (buf[offset] + 1);
     347                                if (offset+1 >= buflen) {
     348                                        return 0;
     349                                }
    333350                                p = &buf[offset+1];
    334351                        }
     
    405422******************************************************************/
    406423
    407 static int put_res_rec(char *buf,int offset,struct res_rec *recs,int count)
     424static int put_res_rec(char *buf, size_t buflen, int offset,struct res_rec *recs,int count)
    408425{
    409426        int ret=0;
     
    411428
    412429        for (i=0;i<count;i++) {
    413                 int l = put_nmb_name(buf,offset,&recs[i].rr_name);
     430                int l = put_nmb_name(buf,buflen,offset,&recs[i].rr_name);
    414431                offset += l;
    415432                ret += l;
     
    888905                        dgram->header.msg_type == 0x11 ||
    889906                        dgram->header.msg_type == 0x12) {
    890                 offset += put_nmb_name((char *)ubuf,offset,&dgram->source_name);
    891                 offset += put_nmb_name((char *)ubuf,offset,&dgram->dest_name);
     907                offset += put_nmb_name((char *)ubuf,len,offset,&dgram->source_name);
     908                offset += put_nmb_name((char *)ubuf,len,offset,&dgram->dest_name);
    892909        }
    893910
     
    918935        memset( (char *)n, '\0', sizeof(struct nmb_name) );
    919936        fstrcpy(unix_name, name);
    920         strupper_m(unix_name);
     937        (void)strupper_m(unix_name);
    921938        push_ascii(n->name, unix_name, sizeof(n->name), STR_TERMINATE);
    922939        n->name_type = (unsigned int)type & 0xFF;
    923         push_ascii(n->scope,  global_scope(), 64, STR_TERMINATE);
     940        push_ascii(n->scope,  lp_netbios_scope(), 64, STR_TERMINATE);
    924941}
    925942
     
    980997                if (len) {
    981998                        /* Length check. */
    982                         int extra = put_nmb_name(NULL,offset,
     999                        int extra = put_nmb_name(NULL,0,offset,
    9831000                                        &nmb->question.question_name);
    9841001                        if (offset + extra > len) {
     
    9861003                        }
    9871004                }
    988                 offset += put_nmb_name((char *)ubuf,offset,
     1005                offset += put_nmb_name((char *)ubuf,len,offset,
    9891006                                &nmb->question.question_name);
    9901007                if (buf) {
     
    9981015                if (len) {
    9991016                        /* Length check. */
    1000                         int extra = put_res_rec(NULL,offset,nmb->answers,
     1017                        int extra = put_res_rec(NULL,0,offset,nmb->answers,
    10011018                                        nmb->header.ancount);
    10021019                        if (offset + extra > len) {
     
    10041021                        }
    10051022                }
    1006                 offset += put_res_rec((char *)ubuf,offset,nmb->answers,
     1023                offset += put_res_rec((char *)ubuf,len,offset,nmb->answers,
    10071024                                nmb->header.ancount);
    10081025        }
     
    10111028                if (len) {
    10121029                        /* Length check. */
    1013                         int extra = put_res_rec(NULL,offset,nmb->nsrecs,
     1030                        int extra = put_res_rec(NULL,0,offset,nmb->nsrecs,
    10141031                                nmb->header.nscount);
    10151032                        if (offset + extra > len) {
     
    10171034                        }
    10181035                }
    1019                 offset += put_res_rec((char *)ubuf,offset,nmb->nsrecs,
     1036                offset += put_res_rec((char *)ubuf,len,offset,nmb->nsrecs,
    10201037                                nmb->header.nscount);
    10211038        }
     
    10491066                if (len) {
    10501067                        /* Length check. */
    1051                         int extra = put_res_rec(NULL,offset,nmb->additional,
     1068                        int extra = put_res_rec(NULL,0,offset,nmb->additional,
    10521069                                nmb->header.arcount);
    10531070                        if (offset + extra > len) {
     
    10551072                        }
    10561073                }
    1057                 offset += put_res_rec((char *)ubuf,offset,nmb->additional,
     1074                offset += put_res_rec((char *)ubuf,len,offset,nmb->additional,
    10581075                        nmb->header.arcount);
    10591076        }
     
    11321149***************************************************************************/
    11331150
    1134 int matching_len_bits(unsigned char *p1, unsigned char *p2, size_t len)
     1151int matching_len_bits(const unsigned char *p1, const unsigned char *p2, size_t len)
    11351152{
    11361153        size_t i, j;
     
    12461263        char *p;
    12471264
    1248         result = talloc_array(mem_ctx, char, 33 + strlen(global_scope()) + 2);
     1265        result = talloc_array(mem_ctx, char, 33 + strlen(lp_netbios_scope()) + 2);
    12491266        if (result == NULL) {
    12501267                return NULL;
     
    12621279
    12631280                pull_ascii_fstring(buf_unix, In);
    1264                 strupper_m(buf_unix);
     1281                if (!strupper_m(buf_unix)) {
     1282                        return NULL;
     1283                }
    12651284
    12661285                push_ascii_nstring(buf_dos, buf_unix);
     
    12811300
    12821301        /* Add the scope string. */
    1283         for( i = 0, len = 0; *(global_scope()) != '\0'; i++, len++ ) {
    1284                 switch( (global_scope())[i] ) {
     1302        for( i = 0, len = 0; *(lp_netbios_scope()) != '\0'; i++, len++ ) {
     1303                switch( (lp_netbios_scope())[i] ) {
    12851304                        case '\0':
    12861305                                p[0] = len;
     
    12941313                                break;
    12951314                        default:
    1296                                 p[len+1] = (global_scope())[i];
     1315                                p[len+1] = (lp_netbios_scope())[i];
    12971316                                break;
    12981317                }
     
    13161335        c = *(unsigned char *)(buf+ofs);
    13171336        if ((c & 0xC0) == 0xC0) {
    1318                 uint16 l = 0;
     1337                uint16_t l = 0;
    13191338
    13201339                if (ofs > buf_len - 1) {
Note: See TracChangeset for help on using the changeset viewer.