Commit c717d8bf13d4c24372c4885eefa821ec76378d2b

Authored by balrog
1 parent 7241f532

Simplify guess_disk_lchs - should fix Windows stack corruption spotted by TeLeMa…

…n (patch by Tristan Gingold).


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3953 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 1 additions and 8 deletions
hw/ide.c
... ... @@ -2474,22 +2474,17 @@ struct partition {
2474 2474 static int guess_disk_lchs(IDEState *s,
2475 2475 int *pcylinders, int *pheads, int *psectors)
2476 2476 {
2477   - uint8_t *buf;
  2477 + uint8_t *buf = s->io_buffer;
2478 2478 int ret, i, heads, sectors, cylinders;
2479 2479 struct partition *p;
2480 2480 uint32_t nr_sects;
2481 2481  
2482   - buf = qemu_memalign(512, 512);
2483   - if (buf == NULL)
2484   - return -1;
2485 2482 ret = bdrv_read(s->bs, 0, buf, 1);
2486 2483 if (ret < 0) {
2487   - qemu_free(buf);
2488 2484 return -1;
2489 2485 }
2490 2486 /* test msdos magic */
2491 2487 if (buf[510] != 0x55 || buf[511] != 0xaa) {
2492   - qemu_free(buf);
2493 2488 return -1;
2494 2489 }
2495 2490 for(i = 0; i < 4; i++) {
... ... @@ -2512,11 +2507,9 @@ static int guess_disk_lchs(IDEState *s,
2512 2507 printf("guessed geometry: LCHS=%d %d %d\n",
2513 2508 cylinders, heads, sectors);
2514 2509 #endif
2515   - qemu_free(buf);
2516 2510 return 0;
2517 2511 }
2518 2512 }
2519   - qemu_free(buf);
2520 2513 return -1;
2521 2514 }
2522 2515  
... ...