diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2019-01-26 15:45:54 +0100 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2019-01-26 15:47:34 +0100 |
commit | d51ea9719bbc1ca9897fd4e9171bfa4e9aabe5e0 (patch) | |
tree | 2ab10a06ee04af0a642c6fa39f261a139664af23 /libgphoto2_port | |
parent | 0351eba2f0907314421ec79005de0822055fd535 (diff) | |
download | libgphoto2-d51ea9719bbc1ca9897fd4e9171bfa4e9aabe5e0.tar.gz |
add a generic fuzz mode we can use for other cameras
Diffstat (limited to 'libgphoto2_port')
-rw-r--r-- | libgphoto2_port/vusb/vcamera.c | 7 | ||||
-rw-r--r-- | libgphoto2_port/vusb/vcamera.h | 4 | ||||
-rw-r--r-- | libgphoto2_port/vusb/vusb.c | 6 |
3 files changed, 17 insertions, 0 deletions
diff --git a/libgphoto2_port/vusb/vcamera.c b/libgphoto2_port/vusb/vcamera.c index 9d82fef44..4939f3b6e 100644 --- a/libgphoto2_port/vusb/vcamera.c +++ b/libgphoto2_port/vusb/vcamera.c @@ -1942,6 +1942,7 @@ vcam_read(vcamera*cam, int ep, unsigned char *data, int bytes) { fwrite(cam->inbulk, 1, toread, cam->fuzzf); /* fallthrough */ } else { +#ifdef FUZZ_PTP /* for reading fuzzer data */ if (cam->fuzzpending) { toread = cam->fuzzpending; @@ -1968,6 +1969,12 @@ vcam_read(vcamera*cam, int ep, unsigned char *data, int bytes) { hasread += 4; /* readd size */ } +#else + /* just return a blob of data in generic fuzzing */ + hasread = fread (data, 1, bytes, cam->fuzzf); + if (!hasread && feof(cam->fuzzf)) + return GP_ERROR_IO_READ; +#endif #if 0 for (i=0;i<toread;i++) data[i] ^= cam->inbulk[i]; diff --git a/libgphoto2_port/vusb/vcamera.h b/libgphoto2_port/vusb/vcamera.h index 7000087eb..b3c57258c 100644 --- a/libgphoto2_port/vusb/vcamera.h +++ b/libgphoto2_port/vusb/vcamera.h @@ -22,6 +22,8 @@ #ifndef __VCAMERA_H__ #define __VCAMERA_H__ +#define FUZZ_PTP + #include <stdio.h> typedef struct ptpcontainer { @@ -48,6 +50,8 @@ typedef struct vcamera { int (*readint)(struct vcamera*, unsigned char *data, int bytes, int timeout); int (*write)(struct vcamera*, int ep, const unsigned char *data, int bytes); + unsigned short vendor, product; /* for generic fuzzing */ + vcameratype type; unsigned char *inbulk; int nrinbulk; diff --git a/libgphoto2_port/vusb/vusb.c b/libgphoto2_port/vusb/vusb.c index f4b4ef22e..d097f565b 100644 --- a/libgphoto2_port/vusb/vusb.c +++ b/libgphoto2_port/vusb/vusb.c @@ -269,7 +269,11 @@ gp_port_vusb_msg_read_lib(GPPort *port, int request, int value, int index, static int gp_port_vusb_find_device_lib(GPPort *port, int idvendor, int idproduct) { +#ifdef FUZZ_PTP if ((idvendor == 0x04b0) && (idproduct == 0x0437)) { /* Nikon D750 */ +#else + if ((idvendor == 0x0851) && (idproduct == 0x1542)) { /* sipix blink */ +#endif port->settings.usb.config = 1; port->settings.usb.interface = 1; port->settings.usb.altsetting = 1; @@ -289,6 +293,7 @@ gp_port_vusb_find_device_by_class_lib(GPPort *port, int class, int subclass, int { gp_log(GP_LOG_DEBUG,__FUNCTION__,"(0x%02x,0x%02x,0x%02x)", class, subclass, protocol); +#ifdef FUZZ_PTP if ((class == 6) && (subclass == 1) && (protocol == 1)) { port->settings.usb.config = 1; port->settings.usb.interface = 1; @@ -301,6 +306,7 @@ gp_port_vusb_find_device_by_class_lib(GPPort *port, int class, int subclass, int return GP_OK; } return GP_ERROR_IO_USB_FIND; +#endif } |