Re: [patch, libv4l]: fix integer overflow
Hi! > > This bit me while trying to use absolute exposure time on Nokia N900: > > > > Can someone apply it to libv4l2 tree? Could I get some feedback on the > > other patches? Is this the way to submit patches to libv4l2? > > Yes, it is. But I do need a Signed-off-by from you. Ping? Can I get you to apply the patches? Thanks, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html signature.asc Description: Digital signature
Re: [patch, libv4l]: fix integer overflow
Hi! > > This bit me while trying to use absolute exposure time on Nokia N900: > > > > Can someone apply it to libv4l2 tree? Could I get some feedback on the > > other patches? Is this the way to submit patches to libv4l2? > > Yes, it is. But I do need a Signed-off-by from you. Ok, that should be it for today. I also put all but the first patch into the git, at https://gitlab.com/tui/v4l-utils/tree/merge Best regards, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html signature.asc Description: Digital signature
Re: [patch, libv4l]: fix integer overflow
Fix integer overflow with EXPOSURE_ABSOLUTE. This is problem for example with Nokia N900. Signed-off-by: Pavel Machek diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c index e795aee..189fc06 100644 --- a/lib/libv4l2/libv4l2.c +++ b/lib/libv4l2/libv4l2.c @@ -1776,7 +1776,7 @@ int v4l2_set_control(int fd, int cid, int value) if (qctrl.type == V4L2_CTRL_TYPE_BOOLEAN) ctrl.value = value ? 1 : 0; else - ctrl.value = (value * (qctrl.maximum - qctrl.minimum) + 32767) / 65535 + + ctrl.value = ((long long) value * (qctrl.maximum - qctrl.minimum) + 32767) / 65535 + qctrl.minimum; result = v4lconvert_vidioc_s_ctrl(devices[index].convert, &ctrl); @@ -1812,7 +1812,7 @@ int v4l2_get_control(int fd, int cid) if (v4l2_propagate_ioctl(index, VIDIOC_G_CTRL, &ctrl)) return -1; - return ((ctrl.value - qctrl.minimum) * 65535 + + return (((long long) ctrl.value - qctrl.minimum) * 65535 + (qctrl.maximum - qctrl.minimum) / 2) / (qctrl.maximum - qctrl.minimum); } -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html signature.asc Description: Digital signature
Re: [patch, libv4l]: fix integer overflow
On Tue 2017-05-09 08:32:20, Hans Verkuil wrote: > On 05/09/2017 08:29 AM, Hans Verkuil wrote: > > On 05/09/2017 12:28 AM, Pavel Machek wrote: > >> Hi! > >> > >> This bit me while trying to use absolute exposure time on Nokia N900: > >> > >> Can someone apply it to libv4l2 tree? Could I get some feedback on the > >> other patches? Is this the way to submit patches to libv4l2? > > > > Yes, it is. But I do need a Signed-off-by from you. > > I saw other patches from you for libv4l without a Signed-off-by. Can you > check them and reply with the Signed-off-by line? Thanks for quick reply. Yes, will do. Best regards, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html signature.asc Description: Digital signature
Re: [patch, libv4l]: fix integer overflow
On 05/09/2017 08:29 AM, Hans Verkuil wrote: > On 05/09/2017 12:28 AM, Pavel Machek wrote: >> Hi! >> >> This bit me while trying to use absolute exposure time on Nokia N900: >> >> Can someone apply it to libv4l2 tree? Could I get some feedback on the >> other patches? Is this the way to submit patches to libv4l2? > > Yes, it is. But I do need a Signed-off-by from you. I saw other patches from you for libv4l without a Signed-off-by. Can you check them and reply with the Signed-off-by line? Thanks! Hans > > Regards, > > Hans > >> >> Thanks, >> Pavel >> >> commit 0484e39ec05fdc644191e7c334a7ebfff9cb2ec5 >> Author: Pavel >> Date: Mon May 8 21:52:02 2017 +0200 >> >> Fix integer overflow with EXPOSURE_ABSOLUTE. >> >> diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c >> index e795aee..189fc06 100644 >> --- a/lib/libv4l2/libv4l2.c >> +++ b/lib/libv4l2/libv4l2.c >> @@ -1776,7 +1776,7 @@ int v4l2_set_control(int fd, int cid, int value) >> if (qctrl.type == V4L2_CTRL_TYPE_BOOLEAN) >> ctrl.value = value ? 1 : 0; >> else >> -ctrl.value = (value * (qctrl.maximum - qctrl.minimum) + >> 32767) / 65535 + >> +ctrl.value = ((long long) value * (qctrl.maximum - >> qctrl.minimum) + 32767) / 65535 + >> qctrl.minimum; >> >> result = v4lconvert_vidioc_s_ctrl(devices[index].convert, >> &ctrl); >> @@ -1812,7 +1812,7 @@ int v4l2_get_control(int fd, int cid) >> if (v4l2_propagate_ioctl(index, VIDIOC_G_CTRL, &ctrl)) >> return -1; >> >> -return ((ctrl.value - qctrl.minimum) * 65535 + >> +return (((long long) ctrl.value - qctrl.minimum) * 65535 + >> (qctrl.maximum - qctrl.minimum) / 2) / >> (qctrl.maximum - qctrl.minimum); >> } >> >> >
Re: [patch, libv4l]: fix integer overflow
On 05/09/2017 12:28 AM, Pavel Machek wrote: > Hi! > > This bit me while trying to use absolute exposure time on Nokia N900: > > Can someone apply it to libv4l2 tree? Could I get some feedback on the > other patches? Is this the way to submit patches to libv4l2? Yes, it is. But I do need a Signed-off-by from you. Regards, Hans > > Thanks, > Pavel > > commit 0484e39ec05fdc644191e7c334a7ebfff9cb2ec5 > Author: Pavel > Date: Mon May 8 21:52:02 2017 +0200 > > Fix integer overflow with EXPOSURE_ABSOLUTE. > > diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c > index e795aee..189fc06 100644 > --- a/lib/libv4l2/libv4l2.c > +++ b/lib/libv4l2/libv4l2.c > @@ -1776,7 +1776,7 @@ int v4l2_set_control(int fd, int cid, int value) > if (qctrl.type == V4L2_CTRL_TYPE_BOOLEAN) > ctrl.value = value ? 1 : 0; > else > - ctrl.value = (value * (qctrl.maximum - qctrl.minimum) + > 32767) / 65535 + > + ctrl.value = ((long long) value * (qctrl.maximum - > qctrl.minimum) + 32767) / 65535 + > qctrl.minimum; > > result = v4lconvert_vidioc_s_ctrl(devices[index].convert, > &ctrl); > @@ -1812,7 +1812,7 @@ int v4l2_get_control(int fd, int cid) > if (v4l2_propagate_ioctl(index, VIDIOC_G_CTRL, &ctrl)) > return -1; > > - return ((ctrl.value - qctrl.minimum) * 65535 + > + return (((long long) ctrl.value - qctrl.minimum) * 65535 + > (qctrl.maximum - qctrl.minimum) / 2) / > (qctrl.maximum - qctrl.minimum); > } > >
[patch, libv4l]: fix integer overflow
Hi! This bit me while trying to use absolute exposure time on Nokia N900: Can someone apply it to libv4l2 tree? Could I get some feedback on the other patches? Is this the way to submit patches to libv4l2? Thanks, Pavel commit 0484e39ec05fdc644191e7c334a7ebfff9cb2ec5 Author: Pavel Date: Mon May 8 21:52:02 2017 +0200 Fix integer overflow with EXPOSURE_ABSOLUTE. diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c index e795aee..189fc06 100644 --- a/lib/libv4l2/libv4l2.c +++ b/lib/libv4l2/libv4l2.c @@ -1776,7 +1776,7 @@ int v4l2_set_control(int fd, int cid, int value) if (qctrl.type == V4L2_CTRL_TYPE_BOOLEAN) ctrl.value = value ? 1 : 0; else - ctrl.value = (value * (qctrl.maximum - qctrl.minimum) + 32767) / 65535 + + ctrl.value = ((long long) value * (qctrl.maximum - qctrl.minimum) + 32767) / 65535 + qctrl.minimum; result = v4lconvert_vidioc_s_ctrl(devices[index].convert, &ctrl); @@ -1812,7 +1812,7 @@ int v4l2_get_control(int fd, int cid) if (v4l2_propagate_ioctl(index, VIDIOC_G_CTRL, &ctrl)) return -1; - return ((ctrl.value - qctrl.minimum) * 65535 + + return (((long long) ctrl.value - qctrl.minimum) * 65535 + (qctrl.maximum - qctrl.minimum) / 2) / (qctrl.maximum - qctrl.minimum); } -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html signature.asc Description: Digital signature