Changeset 102 for trunk-3.0/source/nmbd


Ignore:
Timestamp:
Nov 18, 2007, 8:35:45 PM (18 years ago)
Author:
Paul Smedley
Message:

Update to 3.0.27

Location:
trunk-3.0/source/nmbd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk-3.0/source/nmbd/nmbd_packets.c

    r26 r102  
    964964 
    965965        if (data && len) {
     966                if (len < 0 || len > sizeof(nmb->answers->rdata)) {
     967                        DEBUG(5,("reply_netbios_packet: "
     968                                "invalid packet len (%d)\n",
     969                                len ));
     970                        return;
     971                }
    966972                nmb->answers->rdlength = len;
    967973                memcpy(nmb->answers->rdata, data, len);
  • trunk-3.0/source/nmbd/nmbd_processlogon.c

    r26 r102  
    136136                                fstrcpy(reply_name, "\\\\");
    137137                                fstrcat(reply_name, my_name);
    138                                 push_ascii_fstring(q, reply_name);
     138                                push_ascii(q,reply_name,
     139                                                sizeof(outbuf)-PTR_DIFF(q, outbuf),
     140                                                STR_TERMINATE);
    139141                                q = skip_string(outbuf,sizeof(outbuf),q); /* PDC name */
    140142
     
    232234
    233235                                fstrcpy(reply_name,my_name);
    234                                 push_ascii_fstring(q, reply_name);
     236                                push_ascii(q, reply_name,
     237                                                sizeof(outbuf)-PTR_DIFF(q, outbuf),
     238                                                STR_TERMINATE);
    235239                                q = skip_string(outbuf,sizeof(outbuf),q); /* PDC name */
    236240
     
    240244                                        q = ALIGN2(q, outbuf);
    241245
    242                                         q += dos_PutUniCode(q, my_name, sizeof(pstring), True); /* PDC name */
    243                                         q += dos_PutUniCode(q, lp_workgroup(),sizeof(pstring), True); /* Domain name*/
     246                                        q += dos_PutUniCode(q, my_name,
     247                                                sizeof(outbuf) - PTR_DIFF(q, outbuf),
     248                                                True); /* PDC name */
     249                                        q += dos_PutUniCode(q, lp_workgroup(),
     250                                                sizeof(outbuf) - PTR_DIFF(q, outbuf),
     251                                                True); /* Domain name*/
     252                                        if (sizeof(outbuf) - PTR_DIFF(q, outbuf) < 8) {
     253                                                return;
     254                                        }
    244255                                        SIVAL(q, 0, 1); /* our nt version */
    245256                                        SSVAL(q, 4, 0xffff); /* our lmnttoken */
     
    377388                                        q += 2;
    378389
    379                                         q += dos_PutUniCode(q, reply_name,sizeof(pstring), True);
    380                                         q += dos_PutUniCode(q, ascuser, sizeof(pstring), True);
    381                                         q += dos_PutUniCode(q, lp_workgroup(),sizeof(pstring), True);
     390                                        q += dos_PutUniCode(q, reply_name,
     391                                                sizeof(outbuf) - PTR_DIFF(q, outbuf),
     392                                                True);
     393                                        q += dos_PutUniCode(q, ascuser,
     394                                                sizeof(outbuf) - PTR_DIFF(q, outbuf),
     395                                                True);
     396                                        q += dos_PutUniCode(q, lp_workgroup(),
     397                                                sizeof(outbuf) - PTR_DIFF(q, outbuf),
     398                                                True);
    382399                                }
    383400#ifdef HAVE_ADS
     
    395412                                        get_myname(hostname);
    396413       
     414                                        if (sizeof(outbuf) - PTR_DIFF(q, outbuf) < 8) {
     415                                                return;
     416                                        }
    397417                                        if (SVAL(uniuser, 0) == 0) {
    398418                                                SIVAL(q, 0, SAMLOGON_AD_UNK_R); /* user unknown */
     
    407427
    408428                                        /* Push Domain GUID */
     429                                        if (sizeof(outbuf) - PTR_DIFF(q, outbuf) < UUID_FLAT_SIZE) {
     430                                                return;
     431                                        }
    409432                                        if (False == secrets_fetch_domain_guid(domain, &domain_guid)) {
    410433                                                DEBUG(2, ("Could not fetch DomainGUID for %s\n", domain));
     
    422445                                        while ((component = strtok(dc, "."))) {
    423446                                                dc = NULL;
    424                                                 size = push_ascii(&q[1], component, -1, 0);
     447                                                if (sizeof(outbuf) - PTR_DIFF(q, outbuf) < 1) {
     448                                                        return;
     449                                                }
     450                                                size = push_ascii(&q[1], component,
     451                                                        sizeof(outbuf) - PTR_DIFF(q+1, outbuf),
     452                                                        0);
    425453                                                SCVAL(q, 0, size);
    426454                                                q += (size + 1);
     
    428456
    429457                                        /* Unk0 */
     458                                        if (sizeof(outbuf) - PTR_DIFF(q, outbuf) < 4) {
     459                                                return;
     460                                        }
    430461                                        SCVAL(q, 0, 0);
    431462                                        q++;
     
    437468
    438469                                        /* Hostname */
    439                                         size = push_ascii(&q[1], hostname, -1, 0);
     470                                        size = push_ascii(&q[1], hostname,
     471                                                        sizeof(outbuf) - PTR_DIFF(q+1, outbuf),
     472                                                        0);
    440473                                        SCVAL(q, 0, size);
    441474                                        q += (size + 1);
     475
     476                                        if (sizeof(outbuf) - PTR_DIFF(q, outbuf) < 3) {
     477                                                return;
     478                                        }
     479
    442480                                        SCVAL(q, 0, 0xc0 | ((str_offset >> 8) & 0x3F));
    443481                                        SCVAL(q, 1, str_offset & 0xFF);
     
    445483
    446484                                        /* NETBIOS of domain */
    447                                         size = push_ascii(&q[1], lp_workgroup(), -1, STR_UPPER);
     485                                        size = push_ascii(&q[1], lp_workgroup(),
     486                                                        sizeof(outbuf) - PTR_DIFF(q+1, outbuf),
     487                                                        STR_UPPER);
    448488                                        SCVAL(q, 0, size);
    449489                                        q += (size + 1);
    450490
    451491                                        /* Unk1 */
     492                                        if (sizeof(outbuf) - PTR_DIFF(q, outbuf) < 2) {
     493                                                return;
     494                                        }
    452495                                        SCVAL(q, 0, 0);
    453496                                        q++;
    454497
    455498                                        /* NETBIOS of hostname */
    456                                         size = push_ascii(&q[1], my_name, -1, 0);
     499                                        size = push_ascii(&q[1], my_name,
     500                                                        sizeof(outbuf) - PTR_DIFF(q+1, outbuf),
     501                                                        0);
    457502                                        SCVAL(q, 0, size);
    458503                                        q += (size + 1);
    459504
    460505                                        /* Unk2 */
     506                                        if (sizeof(outbuf) - PTR_DIFF(q, outbuf) < 4) {
     507                                                return;
     508                                        }
    461509                                        SCVAL(q, 0, 0);
    462510                                        q++;
     
    464512                                        /* User name */
    465513                                        if (SVAL(uniuser, 0) != 0) {
    466                                                 size = push_ascii(&q[1], ascuser, -1, 0);
     514                                                size = push_ascii(&q[1], ascuser,
     515                                                        sizeof(outbuf) - PTR_DIFF(q+1, outbuf),
     516                                                        0);
    467517                                                SCVAL(q, 0, size);
    468518                                                q += (size + 1);
     
    471521                                        q_orig = q;
    472522                                        /* Site name */
    473                                         size = push_ascii(&q[1], "Default-First-Site-Name", -1, 0);
     523                                        if (sizeof(outbuf) - PTR_DIFF(q, outbuf) < 1) {
     524                                                return;
     525                                        }
     526                                        size = push_ascii(&q[1], "Default-First-Site-Name",
     527                                                        sizeof(outbuf) - PTR_DIFF(q+1, outbuf),
     528                                                        0);
    474529                                        SCVAL(q, 0, size);
    475530                                        q += (size + 1);
     531
     532                                        if (sizeof(outbuf) - PTR_DIFF(q, outbuf) < 18) {
     533                                                return;
     534                                        }
    476535
    477536                                        /* Site name (2) */
     
    495554#endif
    496555
     556                                if (sizeof(outbuf) - PTR_DIFF(q, outbuf) < 8) {
     557                                        return;
     558                                }
     559
    497560                                /* tell the client what version we are */
    498561                                SIVAL(q, 0, ((ntversion < 11) || (SEC_ADS != lp_security())) ? 1 : 13);
Note: See TracChangeset for help on using the changeset viewer.