There is for sure something broken in the owserver, and it can be very 
dangerous from a strict security point of view (buffer overflows and so on). 
However I think that most owserver instances are run in private networks so 
this should not be a major concern. 

For now I would advise you to add a null terminator when you are writing 
“string” data to owserver (something like the alias name) and let us know if 
the problem resurfaces again.

The commit in which Paul added the possibility of non null terminated strings 
on the owserver payload is
https://github.com/owfs/owfs/commit/379f4e926 
<https://github.com/owfs/owfs/commit/379f4e926>
(but let me stress again that it is only my guess that your problem is linked 
to the null terminator, maybe it is something completely different.)

S.


> On 14 Oct 2019, at 00:46, Mick Sulley <m...@sulley.info> wrote:
> 
> Hi Stefano,
> 
> I ran test.py and it completed without error.  I then ran it again and it 
> failed at B9, I ran it several times more and it failed at B9 each time.
> 
> I then made the change you suggested and ran it again, it still failed at B9. 
>  I then rebooted and ran it again and it completed without error.  I then ran 
> it many more times and it still completed without error.  So it would appear 
> that your fix together with a reboot fixes the problem :)
> 
> Is this something which should be fixed in owserver or should it be a 
> discipline on the user to add b'\x00' to any string when writing?
> 
> Mick
> 
> 
> 
> On 13/10/2019 21:25, Stefano Miccoli via Owfs-developers wrote:
>> I had no time to stress test my installation, but let me add some thoughts 
>> here.
>> 
>> The fact that failures are sporadic, and that a reboot makes the system more 
>> resilient, makes me guess that there is a memory leak in owserver. 
>> 
>> I suspect that this could be linked to the way in which strings are treated 
>> in owserver. I clearly remember that when I implemented the write feature I 
>> asked on this list if data sent in a write request should be 
>> null-terminated. Paul replied that this was not necessary, since the length 
>> of the payload is known to owserver.
>> 
>> Therefore the payload for an alias is sent by pyownet as something like
>> 
>> b”/26.123412341234/alias\x00T0”
>> 
>> (where b”\x00” is a null byte in python). This means that on the receiving 
>> side the C code has to add a null terminator to the received alias. So I 
>> would suggest to test writes likes this
>> 
>> owp.write(addr,  newa + b'\x00')
>> 
>> just to see explicitly adding a null terminator on the sending side 
>> mitigates the problem. (Please note that this is just a wild guess, maybe 
>> the problem is in another portion of the code.)
>> 
>> Stefano
>> 
> _______________________________________________
> Owfs-developers mailing list
> Owfs-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/owfs-developers

_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to