No Image

Gzip stdin unexpected end of file

СОДЕРЖАНИЕ
553 просмотров
10 марта 2020

I want sign a tar.gz file and verify the signature for do this i put a signature (in char) in my file. Then i have an another executable who check the sign and if she is good delete this, and to do that i get the content of the file whitout my signature and copy on an other file that a create.

But here is the problem, When a do this my tar.gz original file make a size of 141 and my newly created file make a size of 140. Then when a decompress them i have this error message:

gzip: stdin: unexpected end of file tar:

Child returned status 1 tar:

Error is not recoverable: exiting now

I think when i get the content i forgot a charactere. I tried to use clearerr or feof whitout success.

This is my code for get the content of the signed file:

And when i have created my new file i put the content on them like this:

Why i do: size = size / 4 (i dont know if is the thing to do)

He is a little code for understanding the thing i simply put three int in non lisible charactere

He is the resultat when i dont put the / 4:

And when i put / 4:

In my programe when i delete the / 4 and i decompresse the new .tar.gz i have this error message:

gzip: stdin: invalid compressed data–length error

tar: Child returned status 1

tar: Error is not recoverable: exiting now

So i think without error on my part that i should put the / 4 but i cant explain this.

1 Answer 1

You have a rounding error because you divide the size by 4.

I think the reason why you do size / 4 is because you later do sizeof(int) * size and if you have 4 byte integers then that will cause your size to be 4 times larger than you want. So I think you wrote two bugs there that cancel each other out.

Читайте также:  После установки драйвера реалтек звука нет

I would suggest you remove the / 4 as well as also removing the sizeof(int) * and thus always just let size be the byte count.

As a bonus, this will remove the rounding error that you might have which is probably the whole reason for your problem. Because 141/4 = 35,25 which will be rounded to 35 . Then 35 * sizeof(int) = 35 * 4 = 140 .

Also I would not recommend storing arbitrary binary data of arbitrary size in an array of int because an int array should have a size evenly divisible by 4. I would probably go for a char * or just a void * rather than int * .

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

Are you new to LinuxQuestions.org? Visit the following links:
Site Howto | Site FAQ | Sitemap | Register Now

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux – A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter. For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author’s experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

Читайте также:  Вордпресс всплывающая форма обратной связи

I have downloaded ‘jdk-7u55-linux-x64.tar.gz’

When I execute following command to extract,

But am getting error at last as,

How to resolve this ?

1 Answer 1

Please don’t use sudo unless necessary. If you are extracting this into a directory you have access to, there’s no need for sudo .

Anyway, the error you’re getting is usually due to an incomplete download. The archive ends before the expected footer of the gzipped file. It will probably work fine if you just download it again.

Комментировать
553 просмотров
Комментариев нет, будьте первым кто его оставит

Это интересно
Adblock
detector