debuggers.hg

annotate xen/common/decompress.c @ 22855:1d1eec7e1fb4

xl: Perform minimal validation of virtual disk file while parsing config file

This patch performs some very basic validation on the virtual disk
file passed through the config file. This validation ensures that we
don't go too far with the initialization like spawn qemu and more
while there could be some potentially fundamental issues.

[ Patch fixed up to work with PHYSTYPE_EMPTY 22808:6ec61438713a -iwj ]

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Kamala Narasimhan <kamala.narasimhan@gmail.com>
date Tue Jan 25 18:09:49 2011 +0000 (2011-01-25)
parents d8333666361d
children
rev   line source
keir@20447 1 #include <xen/config.h>
keir@20447 2 #include <xen/init.h>
keir@20447 3 #include <xen/lib.h>
keir@20447 4 #include <xen/string.h>
keir@20447 5 #include <xen/decompress.h>
keir@20447 6
keir@20447 7 static void __init error(const char *msg)
keir@20447 8 {
keir@20447 9 printk("%s\n", msg);
keir@20447 10 }
keir@20447 11
keir@20447 12 int __init decompress(void *inbuf, unsigned int len, void *outbuf)
keir@20447 13 {
keir@20447 14 #if 0 /* Not needed here yet. */
keir@20447 15 if ( len >= 2 &&
keir@20447 16 (!memcmp(inbuf, "\037\213", 2) || !memcmp(inbuf, "\037\236", 2)) )
keir@20447 17 return gunzip(inbuf, len, NULL, NULL, outbuf, NULL, error);
keir@20447 18 #endif
keir@20447 19
keir@20447 20 if ( len >= 3 && !memcmp(inbuf, "\x42\x5a\x68", 3) )
keir@20447 21 return bunzip2(inbuf, len, NULL, NULL, outbuf, NULL, error);
keir@20447 22
keir@20447 23 if ( len >= 2 && !memcmp(inbuf, "\135\000", 2) )
keir@20447 24 return unlzma(inbuf, len, NULL, NULL, outbuf, NULL, error);
keir@20447 25
keir@21663 26 if ( len >= 5 && !memcmp(inbuf, "\x89LZO", 5) )
keir@21663 27 return unlzo(inbuf, len, NULL, NULL, outbuf, NULL, error);
keir@21663 28
keir@20447 29 return 1;
keir@20447 30 }