<p dir="ltr"><br>
On 29 Apr 2016 00:38, "Lubomir I. Ivanov" <<a href="mailto:neolit123@gmail.com">neolit123@gmail.com</a>> wrote:<br>
><br>
> On 28 April 2016 at 11:25, Rick Walsh <<a href="mailto:rickmwalsh@gmail.com">rickmwalsh@gmail.com</a>> wrote:<br>
> > Hi,<br>
> ><br>
> > I was just looking at the layout of the planner, and realized that I<br>
> > couldn't find a use for the use field in the available gasses table.<br>
> ><br>
> > We determine whether or not a segment is closed circuit by whether a<br>
> > setpoint has been set in the dive planner points table.  It doesn't look<br>
> > like we actually use the cylinder use value.<br>
> ><br>
> > Can it be removed?<br>
> ><br>
> > Furthermore, the only way I could find to set the value is to type in the<br>
> > number (0-7) corresponding to the enum.  There's no drop-down of options,<br>
> > and typing the name of the value doesn't work.  There's also a lovely<br>
> > segfault when I enter the value 8 (or any value greater than 7).  If I enter<br>
> > a negative number, the text becomes one of the default dive tags.  Yay<br>
> > memory.  Segfault with value 8.<br>
> ><br>
> > (gdb) bt<br>
> > #0  0x00007ffff0e5db3a in strlen () from /lib64/libc.so.6<br>
> > #1  0x00007ffff1a097c0 in QByteArray::QByteArray(char const*, int) () from<br>
> > /lib64/libQt5Core.so.5<br>
> > #2  0x00000000006d0105 in gettextFromC::trGettext (this=0xcf5d50, text=0xd1<br>
> > <error: Cannot access memory at address 0xd1>)<br>
> >     at /home/rick/src/subsurface/core/gettextfromc.cpp:7<br>
> > #3  0x000000000065470a in CylindersModel::data (this=0xec1020, index=...,<br>
> > role=2) at /home/rick/src/subsurface/qt-models/cylindermodel.cpp:138<br>
><br>
> ^ that would be a:<br>
><br>
> cylindermodel.cpp:137:<br>
><br>
> case USE:<br>
>    ret = gettextFromC::instance()->trGettext(cylinderuse_text[cyl->cylinder_use]);<br>
><br>
> where "cyl" is of type "cylinder_t" and "cylinder_use" is of type<br>
> "enum cylinderuse".<br>
> hmm, but "enum cylinderuse" doesn't have 7 elements, it has 3 (or<br>
> NUM_GAS_USE)...<br>
><br>
> as defined in dive.h:54:<br>
> enum cylinderuse {OC_GAS, DILUENT, OXYGEN, NUM_GAS_USE};<br>
><br>
> are you sure there are 7 elements and if so where are they defined?</p>
<p dir="ltr">Thanks Lubomir.  Yes, there should only be 3 (+1) elements, with values 0 to 2. But after the cylinderuse elements (0-2), it displayed the dive_comp_type elements if values 4-7 were entered. 3 was blank.</p>
<p dir="ltr">><br>
> a patch that can fix the potential buffer overflow of N elements is attached.</p>
<p dir="ltr">I won't have a chance to test for a few days, but it should be relatively easy for someone else to verify the bug, and confirm your fix works.</p>
<p dir="ltr">> but it's probably a good thing to also limit the user on the UI side -<br>
> i.e. once a bad value is entered that field should be auto-adjusted to<br>
> a good value.<br>
><br>
Agreed. I think this should be a drop-down list. Or remove the field from the table entirely. I couldn't work out if/how it's used at all.</p>
<p dir="ltr">Rick<br>
</p>