block.c (c6684249fd35f7e692bcf3039d2fc4b13dd32308) block.c (7cddd3728e964164e99c59e5c9443508d9ee0161)
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 640 unchanged lines hidden (view full) ---

649}
650
651/*
652 * Guess image format by probing its contents.
653 * This is not a good idea when your image is raw (CVE-2008-2004), but
654 * we do it anyway for backward compatibility.
655 *
656 * @buf contains the image's first @buf_size bytes.
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 640 unchanged lines hidden (view full) ---

649}
650
651/*
652 * Guess image format by probing its contents.
653 * This is not a good idea when your image is raw (CVE-2008-2004), but
654 * we do it anyway for backward compatibility.
655 *
656 * @buf contains the image's first @buf_size bytes.
657 * @buf_size is the buffer size in bytes (generally 2048, but can be smaller
658 * if the image file is smaller)
657 * @buf_size is the buffer size in bytes (generally BLOCK_PROBE_BUF_SIZE,
658 * but can be smaller if the image file is smaller)
659 * @filename is its filename.
660 *
661 * For all block drivers, call the bdrv_probe() method to get its
662 * probing score.
663 * Return the first block driver with the highest probing score.
664 */
665static BlockDriver *bdrv_probe_all(const uint8_t *buf, int buf_size,
666 const char *filename)

--- 13 unchanged lines hidden (view full) ---

680
681 return drv;
682}
683
684static int find_image_format(BlockDriverState *bs, const char *filename,
685 BlockDriver **pdrv, Error **errp)
686{
687 BlockDriver *drv;
659 * @filename is its filename.
660 *
661 * For all block drivers, call the bdrv_probe() method to get its
662 * probing score.
663 * Return the first block driver with the highest probing score.
664 */
665static BlockDriver *bdrv_probe_all(const uint8_t *buf, int buf_size,
666 const char *filename)

--- 13 unchanged lines hidden (view full) ---

680
681 return drv;
682}
683
684static int find_image_format(BlockDriverState *bs, const char *filename,
685 BlockDriver **pdrv, Error **errp)
686{
687 BlockDriver *drv;
688 uint8_t buf[2048];
688 uint8_t buf[BLOCK_PROBE_BUF_SIZE];
689 int ret = 0;
690
691 /* Return the raw BlockDriver * to scsi-generic devices or empty drives */
692 if (bs->sg || !bdrv_is_inserted(bs) || bdrv_getlength(bs) == 0) {
693 drv = bdrv_find_format("raw");
694 if (!drv) {
695 error_setg(errp, "Could not find raw image format");
696 ret = -ENOENT;

--- 5387 unchanged lines hidden ---
689 int ret = 0;
690
691 /* Return the raw BlockDriver * to scsi-generic devices or empty drives */
692 if (bs->sg || !bdrv_is_inserted(bs) || bdrv_getlength(bs) == 0) {
693 drv = bdrv_find_format("raw");
694 if (!drv) {
695 error_setg(errp, "Could not find raw image format");
696 ret = -ENOENT;

--- 5387 unchanged lines hidden ---