* [U-Boot] [PATCH 1/2] ubifs: BUG realpath string must be ended with ZERO
@ 2009-04-24 14:36 Ricardo Ribalda Delgado
2009-04-24 14:36 ` [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib Ricardo Ribalda Delgado
2009-04-27 6:58 ` [U-Boot] [PATCH 1/2] ubifs: BUG realpath string must be ended with ZERO Mike Frysinger
0 siblings, 2 replies; 12+ messages in thread
From: Ricardo Ribalda Delgado @ 2009-04-24 14:36 UTC (permalink / raw)
To: u-boot
If the memory used to copy the link_make is "dirty" the string wont
be ended with Zero, throwing out multiple memory bugs.
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@uam.es>
---
v2: better doc and remove duplicated memcpy
fs/ubifs/ubifs.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 32f9ff8..3c8b5da 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -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);
--
1.6.2.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib
2009-04-24 14:36 [U-Boot] [PATCH 1/2] ubifs: BUG realpath string must be ended with ZERO Ricardo Ribalda Delgado
@ 2009-04-24 14:36 ` Ricardo Ribalda Delgado
2009-04-24 15:05 ` Stefan Roese
2009-04-27 6:59 ` Mike Frysinger
2009-04-27 6:58 ` [U-Boot] [PATCH 1/2] ubifs: BUG realpath string must be ended with ZERO Mike Frysinger
1 sibling, 2 replies; 12+ messages in thread
From: Ricardo Ribalda Delgado @ 2009-04-24 14:36 UTC (permalink / raw)
To: u-boot
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 <ricardo.ribalda@uam.es>
---
v2: remove unused parts..
fs/ubifs/ubifs.c | 36 +++++++++++++++++++++++++++++++++++-
fs/ubifs/ubifs.h | 2 --
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 3c8b5da..44bf651 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -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);
+}
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 91351de..a68e4c1 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -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__ */
--
1.6.2.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib
2009-04-24 14:36 ` [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib Ricardo Ribalda Delgado
@ 2009-04-24 15:05 ` Stefan Roese
2009-04-27 6:59 ` Mike Frysinger
1 sibling, 0 replies; 12+ messages in thread
From: Stefan Roese @ 2009-04-24 15:05 UTC (permalink / raw)
To: u-boot
On Friday 24 April 2009, 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!
>
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@uam.es>
Looks better. Below some mostly nitpicking comments.
> ---
> v2: remove unused parts..
> fs/ubifs/ubifs.c | 36 +++++++++++++++++++++++++++++++++++-
> fs/ubifs/ubifs.h | 2 --
> 2 files changed, 35 insertions(+), 3 deletions(-)
>
> diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> index 3c8b5da..44bf651 100644
> --- a/fs/ubifs/ubifs.c
> +++ b/fs/ubifs/ubifs.c
> @@ -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);
Please move those prototypes to the header instead (ubifs.h).
> +
> /*
> * 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);
return is not a function. So just use:
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);
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
=====================================================================
^ permalink raw reply [flat|nested] 12+ messages in thread* [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib
2009-04-24 14:36 ` [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib Ricardo Ribalda Delgado
2009-04-24 15:05 ` Stefan Roese
@ 2009-04-27 6:59 ` Mike Frysinger
2009-04-27 7:06 ` Ricardo Ribalda Delgado
1 sibling, 1 reply; 12+ messages in thread
From: Mike Frysinger @ 2009-04-27 6:59 UTC (permalink / raw)
To: u-boot
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib
2009-04-27 6:59 ` Mike Frysinger
@ 2009-04-27 7:06 ` Ricardo Ribalda Delgado
2009-04-27 7:29 ` Mike Frysinger
0 siblings, 1 reply; 12+ messages in thread
From: Ricardo Ribalda Delgado @ 2009-04-27 7:06 UTC (permalink / raw)
To: u-boot
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
On Mon, Apr 27, 2009 at 08:59, Mike Frysinger <vapier@gentoo.org> wrote:
> 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
>
--
Ricardo Ribalda
http://www.eps.uam.es/~rribalda/
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib
2009-04-27 7:06 ` Ricardo Ribalda Delgado
@ 2009-04-27 7:29 ` Mike Frysinger
2009-04-27 7:36 ` Stefan Roese
0 siblings, 1 reply; 12+ messages in thread
From: Mike Frysinger @ 2009-04-27 7:29 UTC (permalink / raw)
To: u-boot
On Monday 27 April 2009 03:06:26 Ricardo Ribalda Delgado wrote:
fix your top posting. which is to say dont.
> Who is in charge of the lib_generic stuff?
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.
> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib
2009-04-27 7:29 ` Mike Frysinger
@ 2009-04-27 7:36 ` Stefan Roese
2009-04-27 7:48 ` Ricardo Ribalda Delgado
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Roese @ 2009-04-27 7:36 UTC (permalink / raw)
To: u-boot
On Monday 27 April 2009, Mike Frysinger wrote:
> > Who is in charge of the lib_generic stuff?
>
> 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.
Yes, Wolfgang is ion charge for all this 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.
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
=====================================================================
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib
2009-04-27 7:36 ` Stefan Roese
@ 2009-04-27 7:48 ` Ricardo Ribalda Delgado
2009-04-27 7:54 ` Mike Frysinger
0 siblings, 1 reply; 12+ messages in thread
From: Ricardo Ribalda Delgado @ 2009-04-27 7:48 UTC (permalink / raw)
To: u-boot
Hello
I am creating a new function (zunzip). Where this function should be
placed. In zlib.c or in gunzip.c?
Best regards
On Mon, Apr 27, 2009 at 09:36, Stefan Roese <sr@denx.de> wrote:
> On Monday 27 April 2009, Mike Frysinger wrote:
>> > Who is in charge of the lib_generic stuff?
>>
>> 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.
>
> Yes, Wolfgang is ion charge for all this 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.
>
> 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
> =====================================================================
>
--
Ricardo Ribalda
http://www.eps.uam.es/~rribalda/
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 1/2] ubifs: BUG realpath string must be ended with ZERO
2009-04-24 14:36 [U-Boot] [PATCH 1/2] ubifs: BUG realpath string must be ended with ZERO Ricardo Ribalda Delgado
2009-04-24 14:36 ` [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib Ricardo Ribalda Delgado
@ 2009-04-27 6:58 ` Mike Frysinger
1 sibling, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2009-04-27 6:58 UTC (permalink / raw)
To: u-boot
On Friday 24 April 2009 10:36:05 Ricardo Ribalda Delgado wrote:
> If the memory used to copy the link_make is "dirty" the string wont
> be ended with Zero, throwing out multiple memory bugs.
use "NULL" or "NUL", not "Zero". same goes for subject.
> + 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib
@ 2009-04-24 15:23 Ricardo Ribalda Delgado
0 siblings, 0 replies; 12+ messages in thread
From: Ricardo Ribalda Delgado @ 2009-04-24 15:23 UTC (permalink / raw)
To: u-boot
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 <ricardo.ribalda@uam.es>
---
v3: return is not a function. prototypes in header
v2: remove unused parts..
fs/ubifs/ubifs.c | 32 +++++++++++++++++++++++++++++++-
fs/ubifs/ubifs.h | 5 +++--
2 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 3c8b5da..d80774c 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -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!
@@ -41,7 +42,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 +687,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;
+}
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 91351de..2e1680b 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -2172,6 +2172,7 @@ 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);
-
+int ubi_gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp);
+void *zalloc(void *, unsigned, unsigned);
+void zfree(void *, void *, unsigned);
#endif /* !__UBIFS_H__ */
--
1.6.2.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [U-Boot] [PATCH 1/2] lib_generic: gunzip: New function zunzip
@ 2009-04-27 9:19 Ricardo Ribalda Delgado
2009-04-27 9:19 ` [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib Ricardo Ribalda Delgado
0 siblings, 1 reply; 12+ messages in thread
From: Ricardo Ribalda Delgado @ 2009-04-27 9:19 UTC (permalink / raw)
To: u-boot
Separate gunzip in
gunzip: Find the end of the header and call zunzip.
zunzip: Inflate gunzip block without header.
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@uam.es>
---
lib_generic/gunzip.c | 27 ++++++++++++++++++++-------
1 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/lib_generic/gunzip.c b/lib_generic/gunzip.c
index 01a4031..d59a448 100644
--- a/lib_generic/gunzip.c
+++ b/lib_generic/gunzip.c
@@ -39,6 +39,8 @@
int gunzip(void *, int, unsigned char *, unsigned long *);
void *zalloc(void *, unsigned, unsigned);
void zfree(void *, void *, unsigned);
+int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
+ int stoponerr, int offset);
void *zalloc(void *x, unsigned items, unsigned size)
{
@@ -59,8 +61,7 @@ void zfree(void *x, void *addr, unsigned nb)
int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp)
{
- z_stream s;
- int r, i, flags;
+ int i, flags;
/* skip header */
i = 10;
@@ -84,6 +85,18 @@ int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp)
return (-1);
}
+ return zunzip(dst, dstlen, src, lenp, 1, i);
+}
+
+/*
+ * Uncompress blocks compressed with zlib without headers
+ */
+int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
+ int stoponerr, int offset)
+{
+ z_stream s;
+ int r;
+
s.zalloc = zalloc;
s.zfree = zfree;
#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
@@ -95,14 +108,14 @@ int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp)
r = inflateInit2(&s, -MAX_WBITS);
if (r != Z_OK) {
printf ("Error: inflateInit2() returned %d\n", r);
- return (-1);
+ return -1;
}
- s.next_in = src + i;
- s.avail_in = *lenp - i;
+ s.next_in = src + offset;
+ s.avail_in = *lenp - offset;
s.next_out = dst;
s.avail_out = dstlen;
r = inflate(&s, Z_FINISH);
- if (r != Z_STREAM_END) {
+ if ((r != Z_STREAM_END) && (stoponerr==1)) {
printf ("Error: inflate() returned %d\n", r);
inflateEnd(&s);
return (-1);
@@ -110,5 +123,5 @@ int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp)
*lenp = s.next_out - (unsigned char *) dst;
inflateEnd(&s);
- return (0);
+ return 0;
}
--
1.6.2.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib
2009-04-27 9:19 [U-Boot] [PATCH 1/2] lib_generic: gunzip: New function zunzip Ricardo Ribalda Delgado
@ 2009-04-27 9:19 ` Ricardo Ribalda Delgado
0 siblings, 0 replies; 12+ messages in thread
From: Ricardo Ribalda Delgado @ 2009-04-27 9:19 UTC (permalink / raw)
To: u-boot
Blocks compressed with zlib dont have the full gzip header.
Without this patch, block compressed with zlib cannot be readed!
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@uam.es>
---
v3: Create generic function zunzip
v2: remove unused parts.
fs/ubifs/ubifs.c | 7 +++++--
fs/ubifs/ubifs.h | 2 --
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 427d84a..739fb04 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -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,15 +34,17 @@ DECLARE_GLOBAL_DATA_PTR;
/* compress.c */
+int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
+ int stoponerr, int offset);
/*
- * We need a wrapper for gunzip() because the parameters are
+ * We need a wrapper for zunzip() because the parameters are
* incompatible with the lzo decompressor.
*/
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 zunzip(out, *out_len, (unsigned char *)in, &len, 0, 0);
}
/* Fake description object for the "none" compressor */
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 91351de..a68e4c1 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -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__ */
--
1.6.2.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2009-04-27 9:19 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-24 14:36 [U-Boot] [PATCH 1/2] ubifs: BUG realpath string must be ended with ZERO Ricardo Ribalda Delgado
2009-04-24 14:36 ` [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib Ricardo Ribalda Delgado
2009-04-24 15:05 ` Stefan Roese
2009-04-27 6:59 ` Mike Frysinger
2009-04-27 7:06 ` Ricardo Ribalda Delgado
2009-04-27 7:29 ` Mike Frysinger
2009-04-27 7:36 ` Stefan Roese
2009-04-27 7:48 ` Ricardo Ribalda Delgado
2009-04-27 7:54 ` Mike Frysinger
2009-04-27 6:58 ` [U-Boot] [PATCH 1/2] ubifs: BUG realpath string must be ended with ZERO Mike Frysinger
-- strict thread matches above, loose matches on Subject: below --
2009-04-24 15:23 [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib Ricardo Ribalda Delgado
2009-04-27 9:19 [U-Boot] [PATCH 1/2] lib_generic: gunzip: New function zunzip Ricardo Ribalda Delgado
2009-04-27 9:19 ` [U-Boot] [PATCH 2/2] ubifs: BUG: Blocks commpressed with zlib Ricardo Ribalda Delgado
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox