ubifs: BUG realpath string must be ended with ZERO
PATCH 1/2 ubifs: BUG realpath string must be ended with ZERO
If the memory used to copy the link_make is "dirty" the string wont be ended with Zero, throwing out multiple memory bugs.
---
v2: better doc and remove duplicated memcpy
fs/ubifs/ubifs.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
fs/ubifs/ubifs.c +1 -0
@@ -641,6 +641,7 @@ int ubifs_load(char *filename, u32 addr, u32 size) ui =ubifs_inode (inode);if (((inode->i_mode &S_IFMT ) ==S_IFLNK ) && ui->data_len) {memcpy (link_name, ui->data, ui->data_len); + link_name[ui->data_len]='\0' ;printf ("%s is linked to %s!\n" , filename, link_name);ubifs_iput (inode);
Signature · 1 line
1.6.2.4
PATCH 2/2 ubifs: BUG: Blocks commpressed with zlib
Blocks compressed with zlib dont have the full gzip header.
This patch adds a new function to properly handle blocks compressed with zlib.
Without this patch, block compressed with zlib cannot be readed!
---
v2: remove unused parts..
fs/ubifs/ubifs.c | 36 +++++++++++++++++++++++++++++++++++- fs/ubifs/ubifs.h | 2 -- 2 files changed, 35 insertions(+), 3 deletions(-)
fs/ubifs/ubifs.c +35 -1
@@ -24,6 +24,7 @@*/ #include "ubifs.h" +#include <u-boot/zlib.h> #if !defined(CONFIG_SYS_64BIT_VSPRINTF )#warning Please define CONFIG_SYS_64BIT_VSPRINTF for correct output!
@@ -33,6 +34,10 @@ DECLARE_GLOBAL_DATA_PTR;/* compress.c */ +int ubi_gunzip (void *dst,int dstlen,unsigned char *src,unsigned long *lenp); +void *zalloc (void *,unsigned ,unsigned ); +void zfree (void *,void *,unsigned ); +/* * We need a wrapper for gunzip() because the parameters are * incompatible with the lzo decompressor.
@@ -41,7 +46,7 @@ static int gzip_decompress(const unsigned char *in, size_t in_len, unsigned char *out, size_t *out_len) { unsigned long len = in_len; -return gunzip (out, *out_len, (unsigned char *)in, &len); +return ubi_gunzip (out, *out_len, (unsigned char *)in, &len); }/* Fake description object for the "none" compressor */
@@ -686,3 +691,32 @@ out:ubi_close_volume (c->ubi);return err; } + +int ubi_gunzip (void *dst,int dstlen,unsigned char *src,unsigned long *lenp) +{ +z_stream s; +int r, flags; + + s.zalloc = zalloc; + s.zfree = zfree; +#if defined(CONFIG_HW_WATCHDOG ) || defined(CONFIG_WATCHDOG ) + s.outcb = (cb_func )WATCHDOG_RESET ; +#else + s.outcb =Z_NULL ; +#endif /* CONFIG_HW_WATCHDOG */ + + r =inflateInit2 (&s, -MAX_WBITS ); +if (r !=Z_OK ) { +printf ("Error: inflateInit2() returned %d\n" , r); +return (-1 ); + } + s.next_in = src; + s.avail_in = *lenp; + s.next_out = dst; + s.avail_out = dstlen; + r =inflate (&s,Z_FINISH ); + *lenp = s.next_out - (unsigned char *) dst; +inflateEnd (&s); + +return (0 ); +}
fs/ubifs/ubifs.h +0 -2
@@ -2172,6 +2172,4 @@ int ubifs_decompress(const void *buf, int len, void *out, int *out_len,/* todo: Move these to a common U-Boot header */ int lzo1x_decompress_safe (const unsigned char *in,size_t in_len,unsigned char *out,size_t *out_len); -int gunzip (void *dst,int dstlen,unsigned char *src,unsigned long *lenp); -#endif /* !__UBIFS_H__ */
Signature · 1 line
1.6.2.4
PATCH 2/2 ubifs: BUG: Blocks commpressed with zlib
Quoted 8 lines · Ricardo Ribalda Delgado
Blocks compressed with zlib dont have the full gzip header.
This patch adds a new function to properly handle blocks compressed with zlib.
Without this patch, block compressed with zlib cannot be readed!
Signed-off-by Ricardo Ribalda Delgado <[email protected]>
Looks better. Below some mostly nitpicking comments.
Quoted 19 lines
---
v2: remove unused parts..fs/ubifs/ubifs.c | 36 +++++++++++++++++++++++++++++++++++- fs/ubifs/ubifs.h | 2 -- 2 files changed, 35 insertions(+), 3 deletions(-)fs/ubifs/ubifs.c +1
-0@@ -24,6 +24,7 @@*/ #include "ubifs.h" +#include <u-boot/zlib.h> #if !defined(CONFIG_SYS_64BIT_VSPRINTF )#warning Please define CONFIG_SYS_64BIT_VSPRINTF for correct output!
fs/ubifs/ubifs.c DECLARE_GLOBAL_DATA_PTR; · line 40
Quoted 7 lines
fs/ubifs/ubifs.c +3
-0@@ -33,6 +34,10 @@ DECLARE_GLOBAL_DATA_PTR;/* compress.c */ +int ubi_gunzip (void *dst,int dstlen,unsigned char *src,unsigned long *lenp); +void *zalloc (void *,unsigned ,unsigned ); +void zfree (void *,void *,unsigned );
Please move those prototypes to the header instead (ubifs.h).
Quoted 25 lines
fs/ubifs/ubifs.c +1
-0+/* * We need a wrapper for gunzip() because the parameters are * incompatible with the lzo decompressor.
fs/ubifs/ubifs.c +3
-1@@ -41,7 +46,7 @@ static int gzip_decompress(const unsigned char *in, size_t in_len, unsigned char *out, size_t *out_len) { unsigned long len = in_len; -return gunzip (out, *out_len, (unsigned char *)in, &len); +return ubi_gunzip (out, *out_len, (unsigned char *)in, &len); }/* Fake description object for the "none" compressor */ @@ -686,3 +691,32 @@ out:ubi_close_volume (c->ubi);return err; } + +int ubi_gunzip(void *dst, int dstlen, unsigned char *src, unsigned long*lenp) +{
fs/ubifs/ubifs.c +5
-0+z_stream s; +int r, flags; + + s.zalloc = zalloc; + s.zfree = zfree;
fs/ubifs/ubifs.c out: · line 711
Quoted 10 lines
fs/ubifs/ubifs.c +10
-0+#if defined(CONFIG_HW_WATCHDOG ) || defined(CONFIG_WATCHDOG ) + s.outcb = (cb_func )WATCHDOG_RESET ; +#else + s.outcb =Z_NULL ; +#endif /* CONFIG_HW_WATCHDOG */ + + r =inflateInit2 (&s, -MAX_WBITS ); +if (r !=Z_OK ) { +printf ("Error: inflateInit2() returned %d\n" , r); +return (-1 );
return is not a function. So just use:
return -1;
fs/ubifs/ubifs.c out: · line 721
Quoted 10 lines
fs/ubifs/ubifs.c +10
-0+ } + s.next_in = src; + s.avail_in = *lenp; + s.next_out = dst; + s.avail_out = dstlen; + r =inflate (&s,Z_FINISH ); + *lenp = s.next_out - (unsigned char *) dst; +inflateEnd (&s); + +return (0 );
Again, please "return 0;" here.
Thanks.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
PATCH 2/2 ubifs: BUG: Blocks commpressed with zlib
In reply to Ricardo Ribalda DelgadoQuoted 6 lines · On Friday 24 April 2009 10:36:06 Ricardo Ribalda Delgado wrote:
Blocks compressed with zlib dont have the full gzip header.
This patch adds a new function to properly handle blocks compressed with zlib.
Without this patch, block compressed with zlib cannot be readed!
this really should be a common function not specific to ubifs as there are many other opportunities for things to be compressed directly with zlib and not through gzip (splash/video images come to mind).
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090427/a0b21662/attachment.pgp
PATCH 2/2 ubifs: BUG: Blocks commpressed with zlib
Hello Mike:
Who is in charge of the lib_generic stuff?
Meanwhile there is no such a function I will leave it as an extra function. This must be solved ASAP, it is a simply bug that avoid many fs to be mounted properly.
Best regards
Quoted 13 lines · Mike Frysinger
Quoted 6 lines · On Friday 24 April 2009 10:36:06 Ricardo Ribalda Delgado wrote:
Blocks compressed with zlib dont have the full gzip header.
This patch adds a new function to properly handle blocks compressed with zlib.
Without this patch, block compressed with zlib cannot be readed!
this really should be a common function not specific to ubifs as there are many other opportunities for things to be compressed directly with zlib and not through gzip (splash/video images come to mind).
-mike
Signature · 2 lines
Ricardo Ribalda http://www.eps.uam.es/~rribalda/
PATCH 2/2 ubifs: BUG: Blocks commpressed with zlib
On Monday 27 April 2009 03:06:26 Ricardo Ribalda Delgado wrote:
fix your top posting. which is to say dont.
Quoted 1 line
Who is in charge of the
lib_genericstuff?
if there is no one specified in the MAINTAINERS file, then Wolfgang maintains it all. just send it to the u-boot list and someone will pick it up.
Quoted 3 lines
Meanwhile there is no such a function I will leave it as an extra function. This must be solved ASAP, it is a simply bug that avoid many fs to be mounted properly.
by the by, your definition of "ASAP" rarely lines up with anyone else's. you already have a fix so your "ASAP" is taken care of.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090427/a838d641/attachment.pgp
PATCH 2/2 ubifs: BUG: Blocks commpressed with zlib
Quoted 5 lines · Mike Frysinger
Quoted 1 line
Who is in charge of the
lib_genericstuff?if there is no one specified in the
MAINTAINERSfile, then Wolfgang maintains it all. just send it to the u-boot list and someone will pick it up.
Yes, Wolfgang is ion charge for all this stuff.
Quoted 3 lines
Quoted 3 lines
Meanwhile there is no such a function I will leave it as an extra function. This must be solved ASAP, it is a simply bug that avoid many fs to be mounted properly.
We should really fix this properly, as Mike suggested, by moving this function into a common/generic file. It shouldn't be a problem to get it accepted in this release since it's a bug fix. So please resubmit again, this time in lib_generic.
Thanks.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
PATCH 2/2 ubifs: BUG: Blocks commpressed with zlib
Hello
I am creating a new function (zunzip). Where this function should be
placed. In zlib.c or in gunzip.c?
Best regards
Quoted 29 lines · Stefan Roese
Quoted 5 lines · Mike Frysinger
Quoted 1 line
Who is in charge of the
lib_genericstuff?if there is no one specified in the
MAINTAINERSfile, then Wolfgang maintains it all. ?just send it to the u-boot list and someone will pick it up.Yes, Wolfgang is ion charge for all this stuff.
Quoted 3 lines
Quoted 3 lines
Meanwhile there is no such a function I will leave it as an extra function. This must be solved ASAP, it is a simply bug that avoid many fs to be mounted properly.
We should really fix this properly, as Mike suggested, by moving this function into a common/generic file. It shouldn't be a problem to get it accepted in this release since it's a bug fix. So please resubmit again, this time in
lib_generic.Thanks.
Best regards,
Stefan=====================================================================
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 ?Email: office at denx.de
=====================================================================
Signature · 2 lines
Ricardo Ribalda http://www.eps.uam.es/~rribalda/
PATCH 2/2 ubifs: BUG: Blocks commpressed with zlib
Quoted 1 line · On Monday 27 April 2009 03:48:15 Ricardo Ribalda Delgado wrote:
Hello
you're still top posting. please fix the e-mail composer.
Quoted 2 lines
I am creating a new function (zunzip). Where this function should be
placed. Inzlib.cor ingunzip.c?
probably the latter since the former is more "code straight from zlib" -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090427/e3895d24/attachment.pgp
PATCH 1/2 ubifs: BUG realpath string must be ended with ZERO
In reply to Ricardo Ribalda DelgadoQuoted 2 lines · On Friday 24 April 2009 10:36:05 Ricardo Ribalda Delgado wrote:
If the memory used to copy the
link_makeis "dirty" the string wont be ended with Zero, throwing out multiple memory bugs.
use "NULL" or "NUL", not "Zero". same goes for subject.
fs/ubifs/ubifs.c int ubifs_load(char *filename, u32 addr, u32 size) · line 644
Quoted 1 line
fs/ubifs/ubifs.c +1
-0+ link_name[ui->data_len]='\0' ;
need spaces around the equal sign.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090427/5cd89ccd/attachment.pgp