Rizin
unix-like reverse engineering framework and cli tools
zip_fopen_index_encrypted.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "zipint.h"

Go to the source code of this file.

Functions

static zip_file_t_zip_file_new (zip_t *za)
 
ZIP_EXTERN zip_file_tzip_fopen_index_encrypted (zip_t *za, zip_uint64_t index, zip_flags_t flags, const char *password)
 

Function Documentation

◆ _zip_file_new()

static zip_file_t * _zip_file_new ( zip_t za)
static

Definition at line 73 of file zip_fopen_index_encrypted.c.

73  {
74  zip_file_t *zf;
75 
76  if ((zf = (zip_file_t *)malloc(sizeof(struct zip_file))) == NULL) {
78  return NULL;
79  }
80 
81  zf->za = za;
82  zip_error_init(&zf->error);
83  zf->eof = 0;
84  zf->src = NULL;
85 
86  return zf;
87 }
#define NULL
Definition: cris-opc.c:27
ZIP_EXTERN void zip_error_set(zip_error_t *_Nullable, int, int)
Definition: zip_error.c:126
#define ZIP_ER_MEMORY
Definition: zip.h:119
ZIP_EXTERN void zip_error_init(zip_error_t *_Nonnull)
Definition: zip_error.c:59
void * malloc(size_t size)
Definition: malloc.c:123
bool eof
Definition: zipint.h:310
zip_t * za
Definition: zipint.h:308
zip_source_t * src
Definition: zipint.h:311
zip_error_t error
Definition: zipint.h:309
zip_error_t error
Definition: zipint.h:281
zip_t * za
Definition: ziptool.c:79

References zip_file::eof, zip::error, zip_file::error, malloc(), NULL, zip_file::src, zip_file::za, za, ZIP_ER_MEMORY, zip_error_init(), and zip_error_set().

Referenced by zip_fopen_index_encrypted().

◆ zip_fopen_index_encrypted()

ZIP_EXTERN zip_file_t* zip_fopen_index_encrypted ( zip_t za,
zip_uint64_t  index,
zip_flags_t  flags,
const char *  password 
)

Definition at line 44 of file zip_fopen_index_encrypted.c.

44  {
45  zip_file_t *zf;
47 
48  if (password != NULL && password[0] == '\0') {
49  password = NULL;
50  }
51 
52  if ((src = _zip_source_zip_new(za, index, flags, 0, 0, password, &za->error)) == NULL)
53  return NULL;
54 
55  if (zip_source_open(src) < 0) {
58  return NULL;
59  }
60 
61  if ((zf = _zip_file_new(za)) == NULL) {
63  return NULL;
64  }
65 
66  zf->src = src;
67 
68  return zf;
69 }
lzma_index * src
Definition: index.h:567
ZIP_EXTERN int zip_source_open(zip_source_t *_Nonnull)
ZIP_EXTERN void zip_source_free(zip_source_t *_Nullable)
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
void _zip_error_set_from_source(zip_error_t *err, zip_source_t *src)
Definition: zip_error.c:135
static zip_file_t * _zip_file_new(zip_t *za)
zip_source_t * _zip_source_zip_new(zip_t *srcza, zip_uint64_t srcidx, zip_flags_t flags, zip_uint64_t start, zip_uint64_t len, const char *password, zip_error_t *error)

References _zip_error_set_from_source(), _zip_file_new(), _zip_source_zip_new(), zip::error, flags, NULL, zip_file::src, src, za, zip_source_free(), and zip_source_open().

Referenced by zip_fopen(), zip_fopen_encrypted(), and zip_fopen_index().