libcamera: camera: ensure streams belong to camera

Before calling into the pipeline handler make sure the streams provided
by the application actually belongs to the camera.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Niklas Söderlund 2019-02-26 02:56:33 +01:00
parent 7401f5002e
commit a3b8083f54

View file

@ -366,6 +366,11 @@ Camera::streamConfiguration(std::set<Stream *> &streams)
if (disconnected_ || !streams.size()) if (disconnected_ || !streams.size())
return std::map<Stream *, StreamConfiguration>{}; return std::map<Stream *, StreamConfiguration>{};
for (Stream *stream : streams) {
if (streams_.find(stream) == streams_.end())
return std::map<Stream *, StreamConfiguration>{};
}
return pipe_->streamConfiguration(this, streams); return pipe_->streamConfiguration(this, streams);
} }
@ -409,6 +414,11 @@ int Camera::configureStreams(std::map<Stream *, StreamConfiguration> &config)
return -EINVAL; return -EINVAL;
} }
for (auto const &iter : config) {
if (streams_.find(iter.first) == streams_.end())
return -EINVAL;
}
ret = pipe_->configureStreams(this, config); ret = pipe_->configureStreams(this, config);
if (ret) if (ret)
return ret; return ret;