Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 404793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:20:27+00:00 2026-05-12T17:20:27+00:00

Let me explain what I’m trying to realize: I have a encrypted tar file.

  • 0

Let me explain what I’m trying to realize:

I have a encrypted tar file. I can decrypt it in memory, but obviously I can’t write the decrypted data back to hard disk as a real file. The decrypted data is structured as a char* buffer in memory; how can I untar it in memory?

I can’t find answer with libtar library.
I also tried to untar it with execlp("tar", "tar", "-xvO", (void*)0).
But it didn’t work as I thought.

Anyone can give me a hint of the best solution? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:20:27+00:00Added an answer on May 12, 2026 at 5:20 pm

    I made an example, how to read file contents from an in-memory tar. The is_file_in_tar() function returns the length and the starting position of the named file if it is stored in the tar:

    #include <stdio.h> 
    #include <fcntl.h> 
    #include <string.h> 
    #include <sys/mman.h> 
    
    struct tar {
      char name[100];   char _unused[24];
      char size[12];    char _padding[376];
    } *tar;
    
    int is_file_in_tar( struct tar *tar, char *name, char **start, int *length ){
      for( ; tar->name[0]; tar+=1+(*length+511)/512 ){
        sscanf( tar->size, "%o", length);
        if( !strcmp(tar->name,name) ){ *start = (char*)(tar+1); return 1; }
      }
      return 0;
    }
    
    int main(){
      int fd=open( "libtar-1.2.11.tar", O_RDONLY );
      tar=mmap(NULL, 808960, PROT_READ, MAP_PRIVATE, fd, 0);
    
      char *start; int length; char name[]="libtar-1.2.11/TODO";
      if( is_file_in_tar(tar,name,&start,&length) ) printf("%.*s",length,start);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

But of a confusing title so let me explain. I have an array of
Let me explain by an example. In Delphi, you can write procedure TForm1.FormKeyPress(Sender: TObject;
Title might be a bit confusing, so let me explain. I have a website
This question might not seem programming related at first, but let me explain. I'm
How can I document a member inline in .Net? Let me explain. Most tools
Can PL/SQL procedure in Oracle know it's own name? Let me explain: CREATE OR
let me explain my current situation i have a SharePoint site lets say it
Let me explain. I have defined an interface named IEmployee (ID, FirstName and Surname
Let me explain the problem in detail. I have a main git branch on
Let me explain in detail. I have below an object with me - {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.