Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
apk-tools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
61
Issues
61
List
Boards
Labels
Service Desk
Milestones
Merge Requests
15
Merge Requests
15
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpine
apk-tools
Commits
d694025b
Commit
d694025b
authored
Jul 17, 2009
by
Timo Teräs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pkg: fix index generation
that got broke during verify implementation.
parent
3f4f9e99
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
11 deletions
+22
-11
src/gunzip.c
src/gunzip.c
+10
-7
src/package.c
src/package.c
+12
-4
No files found.
src/gunzip.c
View file @
d694025b
...
...
@@ -150,26 +150,26 @@ struct apk_gzip_ostream {
struct
apk_ostream
os
;
struct
apk_ostream
*
output
;
z_stream
zs
;
unsigned
char
buffer
[
8
*
1024
];
};
static
size_t
gzo_write
(
void
*
stream
,
const
void
*
ptr
,
size_t
size
)
{
struct
apk_gzip_ostream
*
gos
=
(
struct
apk_gzip_ostream
*
)
stream
;
unsigned
char
buffer
[
1024
];
size_t
have
;
int
r
;
gos
->
zs
.
avail_in
=
size
;
gos
->
zs
.
next_in
=
(
void
*
)
ptr
;
while
(
gos
->
zs
.
avail_in
)
{
gos
->
zs
.
avail_out
=
sizeof
(
gos
->
buffer
);
gos
->
zs
.
next_out
=
gos
->
buffer
;
gos
->
zs
.
avail_out
=
sizeof
(
buffer
);
gos
->
zs
.
next_out
=
buffer
;
r
=
deflate
(
&
gos
->
zs
,
Z_NO_FLUSH
);
if
(
r
==
Z_STREAM_ERROR
)
return
-
1
;
have
=
sizeof
(
gos
->
buffer
)
-
gos
->
zs
.
avail_out
;
have
=
sizeof
(
buffer
)
-
gos
->
zs
.
avail_out
;
if
(
have
!=
0
)
{
r
=
gos
->
output
->
write
(
gos
->
output
,
gos
->
buffer
,
have
);
r
=
gos
->
output
->
write
(
gos
->
output
,
buffer
,
have
);
if
(
r
!=
have
)
return
-
1
;
}
...
...
@@ -181,11 +181,14 @@ static size_t gzo_write(void *stream, const void *ptr, size_t size)
static
void
gzo_close
(
void
*
stream
)
{
struct
apk_gzip_ostream
*
gos
=
(
struct
apk_gzip_ostream
*
)
stream
;
unsigned
char
buffer
[
1024
];
size_t
have
;
gos
->
zs
.
avail_out
=
sizeof
(
buffer
);
gos
->
zs
.
next_out
=
buffer
;
deflate
(
&
gos
->
zs
,
Z_FINISH
);
have
=
sizeof
(
gos
->
buffer
)
-
gos
->
zs
.
avail_out
;
gos
->
output
->
write
(
gos
->
output
,
gos
->
buffer
,
have
);
have
=
sizeof
(
buffer
)
-
gos
->
zs
.
avail_out
;
gos
->
output
->
write
(
gos
->
output
,
buffer
,
have
);
gos
->
output
->
close
(
gos
->
output
);
deflateEnd
(
&
gos
->
zs
);
...
...
src/package.c
View file @
d694025b
...
...
@@ -259,12 +259,15 @@ int apk_script_type(const char *name)
void
apk_sign_ctx_init
(
struct
apk_sign_ctx
*
ctx
,
int
action
)
{
memset
(
ctx
,
0
,
sizeof
(
struct
apk_sign_ctx
));
switch
(
ctx
->
action
)
{
ctx
->
action
=
action
;
switch
(
action
)
{
case
APK_SIGN_VERIFY
:
ctx
->
md
=
EVP_md_null
();
break
;
case
APK_SIGN_GENERATE_V1
:
ctx
->
md
=
EVP_md5
();
ctx
->
control_started
=
1
;
ctx
->
data_started
=
1
;
break
;
case
APK_SIGN_GENERATE
:
default:
...
...
@@ -272,7 +275,6 @@ void apk_sign_ctx_init(struct apk_sign_ctx *ctx, int action)
ctx
->
md
=
EVP_sha1
();
break
;
}
ctx
->
action
=
action
;
}
...
...
@@ -396,7 +398,7 @@ int apk_sign_ctx_mpart_cb(void *ctx, EVP_MD_CTX *mdctx, int part)
memcmp
(
calculated
,
sctx
->
data_checksum
,
EVP_MD_CTX_size
(
mdctx
))
==
0
)
sctx
->
data_verified
=
1
;
}
else
{
}
else
if
(
!
sctx
->
has_data_checksum
)
{
/* Package identity is checksum of all data */
sctx
->
identity
.
type
=
EVP_MD_CTX_size
(
mdctx
);
EVP_DigestFinal_ex
(
mdctx
,
sctx
->
identity
.
data
,
NULL
);
...
...
@@ -519,7 +521,7 @@ static int read_info_entry(void *ctx, const struct apk_file_info *ae,
if
(
apk_sign_ctx_process_file
(
ri
->
sctx
,
ae
,
is
)
==
0
)
return
0
;
if
(
ri
->
sctx
->
data_started
==
0
&&
ae
->
name
[
0
]
==
'.'
)
{
if
(
ae
->
name
[
0
]
==
'.'
)
{
/* APK 2.0 format */
if
(
strcmp
(
ae
->
name
,
".PKGINFO"
)
==
0
)
{
apk_blob_t
blob
=
apk_blob_from_istream
(
is
,
ae
->
size
);
...
...
@@ -612,6 +614,9 @@ struct apk_package *apk_pkg_read(struct apk_database *db, const char *file,
if
(
sctx
->
action
==
APK_SIGN_VERIFY
&&
!
sctx
->
data_verified
&&
!
(
apk_flags
&
APK_FORCE
))
goto
err
;
if
(
sctx
->
action
!=
APK_SIGN_VERIFY
)
ctx
.
pkg
->
csum
=
sctx
->
identity
;
fprintf
(
stderr
,
"%s: %d
\n
"
,
realfile
,
ctx
.
pkg
->
csum
.
type
);
/* Add implicit busybox dependency if there is scripts */
if
(
ctx
.
has_install
)
{
...
...
@@ -809,6 +814,9 @@ int apk_pkg_write_index_entry(struct apk_package *info,
apk_blob_push_blob
(
&
bbuf
,
APK_BLOB_STR
(
info
->
license
));
apk_blob_push_blob
(
&
bbuf
,
APK_BLOB_STR
(
"
\n
"
));
if
(
APK_BLOB_IS_NULL
(
bbuf
))
return
-
1
;
if
(
os
->
write
(
os
,
buf
,
bbuf
.
ptr
-
buf
)
!=
bbuf
.
ptr
-
buf
)
return
-
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment