On 05.07.2016 17:24, Colin Lord wrote:
> Isolates cloop probing function as part of the modularization process.
> 
> Signed-off-by: Colin Lord <cl...@redhat.com>
> ---
>  block/Makefile.objs   |  2 +-
>  block/cloop.c         | 16 +---------------
>  block/probe/cloop.c   | 17 +++++++++++++++++
>  include/block/probe.h |  1 +
>  4 files changed, 20 insertions(+), 16 deletions(-)
>  create mode 100644 block/probe/cloop.c

Reviewed-by: Max Reitz <mre...@redhat.com>

[...]

> diff --git a/block/probe/cloop.c b/block/probe/cloop.c
> new file mode 100644
> index 0000000..955c29c
> --- /dev/null
> +++ b/block/probe/cloop.c
> @@ -0,0 +1,17 @@
> +#include "qemu/osdep.h"
> +#include "block/probe.h"
> +
> +int cloop_probe(const uint8_t *buf, int buf_size, const char *filename)
> +{
> +    const char *magic_version_2_0 = "#!/bin/sh\n"
> +        "#V2.0 Format\n"
> +        "modprobe cloop file=$0 && mount -r -t iso9660 /dev/cloop $1\n";
> +    int length = strlen(magic_version_2_0);
> +    if (length > buf_size) {
> +        length = buf_size;

Pre-existing, but this seems a bit fishy to me. But, well, as long as
buf_size (BLOCK_PROBE_BUF_SIZE) will actually always be at least the
size of that string...

> +    }
> +    if (!memcmp(magic_version_2_0, buf, length)) {
> +        return 2;
> +    }
> +    return 0;
> +}

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to