add a generic fuzz mode we can use for other cameras
This commit is contained in:
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user