|
Lines 102-109
Link Here
|
| 102 |
char *machine = q; |
102 |
char *machine = q; |
| 103 |
char *user = skip_string(machine,1); |
103 |
char *user = skip_string(machine,1); |
| 104 |
|
104 |
|
|
|
105 |
if (PTR_DIFF(user, buf) >= len) { |
| 106 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 107 |
return; |
| 108 |
} |
| 105 |
getdc = skip_string(user,1); |
109 |
getdc = skip_string(user,1); |
|
|
110 |
|
| 111 |
if (PTR_DIFF(getdc, buf) >= len) { |
| 112 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 113 |
return; |
| 114 |
} |
| 106 |
q = skip_string(getdc,1); |
115 |
q = skip_string(getdc,1); |
|
|
116 |
|
| 117 |
if (PTR_DIFF(q + 5, buf) > len) { |
| 118 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 119 |
return; |
| 120 |
} |
| 107 |
token = SVAL(q,3); |
121 |
token = SVAL(q,3); |
| 108 |
|
122 |
|
| 109 |
fstrcpy(reply_name,my_name); |
123 |
fstrcpy(reply_name,my_name); |
|
Lines 151-157
Link Here
|
| 151 |
} |
165 |
} |
| 152 |
|
166 |
|
| 153 |
getdc = skip_string(machine,1); |
167 |
getdc = skip_string(machine,1); |
|
|
168 |
|
| 169 |
if (PTR_DIFF(getdc, buf) >= len) { |
| 170 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 171 |
return; |
| 172 |
} |
| 154 |
q = skip_string(getdc,1); |
173 |
q = skip_string(getdc,1); |
|
|
174 |
|
| 175 |
if (PTR_DIFF(q, buf) >= len) { |
| 176 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 177 |
return; |
| 178 |
} |
| 155 |
q = ALIGN2(q, buf); |
179 |
q = ALIGN2(q, buf); |
| 156 |
|
180 |
|
| 157 |
/* At this point we can work out if this is a W9X or NT style |
181 |
/* At this point we can work out if this is a W9X or NT style |
|
Lines 165-173
Link Here
|
| 165 |
} else { |
189 |
} else { |
| 166 |
unicomp = q; |
190 |
unicomp = q; |
| 167 |
|
191 |
|
|
|
192 |
if (PTR_DIFF(q, buf) >= len) { |
| 193 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 194 |
return; |
| 195 |
} |
| 196 |
|
| 168 |
/* A full length (NT style) request */ |
197 |
/* A full length (NT style) request */ |
| 169 |
q = skip_unibuf(unicomp, PTR_DIFF(buf + len, unicomp)); |
198 |
q = skip_unibuf(unicomp, PTR_DIFF(buf + len, unicomp)); |
| 170 |
|
199 |
|
|
|
200 |
if (PTR_DIFF(q, buf) >= len) { |
| 201 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 202 |
return; |
| 203 |
} |
| 204 |
|
| 171 |
if (len - PTR_DIFF(q, buf) > 8) { |
205 |
if (len - PTR_DIFF(q, buf) > 8) { |
| 172 |
/* with NT5 clients we can sometimes |
206 |
/* with NT5 clients we can sometimes |
| 173 |
get additional data - a length specificed string |
207 |
get additional data - a length specificed string |
|
Lines 180-185
Link Here
|
| 180 |
} |
214 |
} |
| 181 |
q += 16; |
215 |
q += 16; |
| 182 |
} |
216 |
} |
|
|
217 |
|
| 218 |
if (PTR_DIFF(q + 8, buf) > len) { |
| 219 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 220 |
return; |
| 221 |
} |
| 222 |
|
| 183 |
ntversion = IVAL(q, 0); |
223 |
ntversion = IVAL(q, 0); |
| 184 |
lmnttoken = SVAL(q, 4); |
224 |
lmnttoken = SVAL(q, 4); |
| 185 |
lm20token = SVAL(q, 6); |
225 |
lm20token = SVAL(q, 6); |
|
Lines 240-249
Link Here
|
| 240 |
fstring asccomp; |
280 |
fstring asccomp; |
| 241 |
|
281 |
|
| 242 |
q += 2; |
282 |
q += 2; |
|
|
283 |
|
| 284 |
if (PTR_DIFF(q, buf) >= len) { |
| 285 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 286 |
return; |
| 287 |
} |
| 288 |
|
| 243 |
unicomp = q; |
289 |
unicomp = q; |
| 244 |
uniuser = skip_unibuf(unicomp, PTR_DIFF(buf+len, unicomp)); |
290 |
uniuser = skip_unibuf(unicomp, PTR_DIFF(buf+len, unicomp)); |
|
|
291 |
|
| 292 |
if (PTR_DIFF(uniuser, buf) >= len) { |
| 293 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 294 |
return; |
| 295 |
} |
| 296 |
|
| 245 |
getdc = skip_unibuf(uniuser,PTR_DIFF(buf+len, uniuser)); |
297 |
getdc = skip_unibuf(uniuser,PTR_DIFF(buf+len, uniuser)); |
|
|
298 |
|
| 299 |
if (PTR_DIFF(getdc, buf) >= len) { |
| 300 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 301 |
return; |
| 302 |
} |
| 303 |
|
| 246 |
q = skip_string(getdc,1); |
304 |
q = skip_string(getdc,1); |
|
|
305 |
|
| 306 |
if (PTR_DIFF(q + 8, buf) >= len) { |
| 307 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 308 |
return; |
| 309 |
} |
| 310 |
|
| 247 |
q += 4; /* Account Control Bits - indicating username type */ |
311 |
q += 4; /* Account Control Bits - indicating username type */ |
| 248 |
domainsidsize = IVAL(q, 0); |
312 |
domainsidsize = IVAL(q, 0); |
| 249 |
q += 4; |
313 |
q += 4; |
|
Lines 270-275
Link Here
|
| 270 |
q += 16; |
334 |
q += 16; |
| 271 |
} |
335 |
} |
| 272 |
|
336 |
|
|
|
337 |
if (PTR_DIFF(q + 8, buf) > len) { |
| 338 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 339 |
return; |
| 340 |
} |
| 341 |
|
| 273 |
ntversion = IVAL(q, 0); |
342 |
ntversion = IVAL(q, 0); |
| 274 |
lmnttoken = SVAL(q, 4); |
343 |
lmnttoken = SVAL(q, 4); |
| 275 |
lm20token = SVAL(q, 6); |
344 |
lm20token = SVAL(q, 6); |
|
Lines 458-463
Link Here
|
| 458 |
|
527 |
|
| 459 |
/* Header */ |
528 |
/* Header */ |
| 460 |
|
529 |
|
|
|
530 |
if (PTR_DIFF(q + 16, buf) >= len) { |
| 531 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 532 |
return; |
| 533 |
} |
| 534 |
|
| 461 |
low_serial = IVAL(q, 0); q += 4; /* Low serial number */ |
535 |
low_serial = IVAL(q, 0); q += 4; /* Low serial number */ |
| 462 |
|
536 |
|
| 463 |
q += 4; /* Date/time */ |
537 |
q += 4; /* Date/time */ |
|
Lines 467-480
Link Here
|
| 467 |
/* Domain info */ |
541 |
/* Domain info */ |
| 468 |
|
542 |
|
| 469 |
q = skip_string(q, 1); /* PDC name */ |
543 |
q = skip_string(q, 1); /* PDC name */ |
|
|
544 |
|
| 545 |
if (PTR_DIFF(q, buf) >= len) { |
| 546 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 547 |
return; |
| 548 |
} |
| 549 |
|
| 470 |
q = skip_string(q, 1); /* Domain name */ |
550 |
q = skip_string(q, 1); /* Domain name */ |
|
|
551 |
|
| 552 |
if (PTR_DIFF(q, buf) >= len) { |
| 553 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 554 |
return; |
| 555 |
} |
| 556 |
|
| 471 |
q = skip_unibuf(q, PTR_DIFF(buf + len, q)); /* Unicode PDC name */ |
557 |
q = skip_unibuf(q, PTR_DIFF(buf + len, q)); /* Unicode PDC name */ |
|
|
558 |
|
| 559 |
if (PTR_DIFF(q, buf) >= len) { |
| 560 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 561 |
return; |
| 562 |
} |
| 563 |
|
| 472 |
q = skip_unibuf(q, PTR_DIFF(buf + len, q)); /* Unicode domain name */ |
564 |
q = skip_unibuf(q, PTR_DIFF(buf + len, q)); /* Unicode domain name */ |
| 473 |
|
565 |
|
| 474 |
/* Database info */ |
566 |
/* Database info */ |
| 475 |
|
567 |
|
|
|
568 |
if (PTR_DIFF(q + 2, buf) >= len) { |
| 569 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 570 |
return; |
| 571 |
} |
| 572 |
|
| 476 |
db_count = SVAL(q, 0); q += 2; |
573 |
db_count = SVAL(q, 0); q += 2; |
| 477 |
|
574 |
|
|
|
575 |
if (PTR_DIFF(q + (db_count*20), buf) >= len) { |
| 576 |
DEBUG(0,("process_logon_packet: bad packet\n")); |
| 577 |
return; |
| 578 |
} |
| 579 |
|
| 478 |
db_info = (struct sam_database_info *) |
580 |
db_info = (struct sam_database_info *) |
| 479 |
malloc(sizeof(struct sam_database_info) * db_count); |
581 |
malloc(sizeof(struct sam_database_info) * db_count); |
| 480 |
|
582 |
|