Serg,

I think your second solution is the correct one.

An explantation:
The string values that OWFS generates aren't null-terminated. (The file length is correct, however). So adding buf[len]='\0' may write beyond the end of the buffer.

Thanks for chasing this down!

Paul Alfille

On 11/8/06, Serg Oskin <[EMAIL PROTECTED]> wrote:
Hello All!

I had here such problem:


# owfs -t 3 -d /dev/ttyS2 /mnt/1wire
# while : ; do
>   echo 1 >/mnt/1wire/simultaneous/temperature
>   cat /mnt/1wire/simultaneous/temperature
>   echo ""
>   sleep 4
done
1
1
1DPD^Pcat: /mnt/1wire/simultaneous/temperature: Numerical result out of range


I have corrected It here so:
http://owfs.cvs.sourceforge.net/owfs/owfs/module/owlib/src/c/ow_read.c?r1=1.104&r2=1.105&sortby=date

However there is one more variant of the decision of this problem:


--- ow_write.c.orig
+++ ow_write.c
...
  static int FS_w_single(const char * buf, const size_t size, const off_t offset
, const struct parsedname * pn) {
-    size_t fl = FileLength(pn) ;
+    size_t fl = FileLength(pn), lcbuf = 0 ;
      int ret ;
...
              ret = FS_input_yesno( &Y, buf, size ) ;
-            if ( cbuf && ret==0 ) FS_output_integer(Y,cbuf,fl,pn) ; /*
post-parse cachable string creation */
+            if ( cbuf && ret==0 ) lcbuf = FS_output_integer(Y,cbuf,fl,pn) ; /*
post-parse cachable string creation */
              ret = ret || (pn->ft-> write.y)(&Y,pn) ;
...
        //printf("CACHEADD: [%i] %s\n",strlen(cbuf),cbuf);
-        Cache_Add( cbuf, strlen(cbuf), pn ) ;
+        Cache_Add( cbuf, lcbuf, pn ) ;
      } else if ( IsLocalCacheEnabled(pn) ) {
...


How you consider what of them more correct? :)

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to