> > +static void usb_mtp_write_data(MTPState *s)
> > +{
> > +    MTPData *d = s->data_out;
> > +    MTPObject *parent =
> > +        usb_mtp_object_lookup(s, s->dataset.parent_handle);
> > +    char *path = NULL;
> > +    int rc = -1;
> > +    mode_t mask = 0644;
> > +
> > +    assert(d != NULL);
> > +
> 
> 
> Somewhere in here should surely be validating the "readonly" flag.
> 
> > +    if (parent == NULL || !s->write_pending) {

Does happens here.  With a readonly device write_pending should
never be true.

> > +        usb_mtp_queue_result(s, RES_INVALID_OBJECTINFO, d->trans,
> > +                             0, 0, 0, 0);
> > +        return;
> > +    }

But adding an "assert(!readonly)" here as double-check surely doesn't hurt.

cheers,
  Gerd


Reply via email to