| @@ -1,23 +1,23 @@ | | | @@ -1,23 +1,23 @@ |
1 | /* $NetBSD: pkg_signature.c,v 1.10 2010/02/20 04:40:03 joerg Exp $ */ | | 1 | /* $NetBSD: pkg_signature.c,v 1.11 2013/09/11 14:10:05 khorben Exp $ */ |
2 | | | 2 | |
3 | #if HAVE_CONFIG_H | | 3 | #if HAVE_CONFIG_H |
4 | #include "config.h" | | 4 | #include "config.h" |
5 | #endif | | 5 | #endif |
6 | #include <nbcompat.h> | | 6 | #include <nbcompat.h> |
7 | #if HAVE_SYS_CDEFS_H | | 7 | #if HAVE_SYS_CDEFS_H |
8 | #include <sys/cdefs.h> | | 8 | #include <sys/cdefs.h> |
9 | #endif | | 9 | #endif |
10 | __RCSID("$NetBSD: pkg_signature.c,v 1.10 2010/02/20 04:40:03 joerg Exp $"); | | 10 | __RCSID("$NetBSD: pkg_signature.c,v 1.11 2013/09/11 14:10:05 khorben Exp $"); |
11 | | | 11 | |
12 | /*- | | 12 | /*- |
13 | * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>. | | 13 | * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>. |
14 | * All rights reserved. | | 14 | * All rights reserved. |
15 | * | | 15 | * |
16 | * Redistribution and use in source and binary forms, with or without | | 16 | * Redistribution and use in source and binary forms, with or without |
17 | * modification, are permitted provided that the following conditions | | 17 | * modification, are permitted provided that the following conditions |
18 | * are met: | | 18 | * are met: |
19 | * | | 19 | * |
20 | * 1. Redistributions of source code must retain the above copyright | | 20 | * 1. Redistributions of source code must retain the above copyright |
21 | * notice, this list of conditions and the following disclaimer. | | 21 | * notice, this list of conditions and the following disclaimer. |
22 | * 2. Redistributions in binary form must reproduce the above copyright | | 22 | * 2. Redistributions in binary form must reproduce the above copyright |
23 | * notice, this list of conditions and the following disclaimer in | | 23 | * notice, this list of conditions and the following disclaimer in |
| @@ -315,30 +315,27 @@ cleanup: | | | @@ -315,30 +315,27 @@ cleanup: |
315 | int | | 315 | int |
316 | pkg_verify_signature(const char *archive_name, struct archive **archive, | | 316 | pkg_verify_signature(const char *archive_name, struct archive **archive, |
317 | struct archive_entry **entry, char **pkgname) | | 317 | struct archive_entry **entry, char **pkgname) |
318 | { | | 318 | { |
319 | struct signature_archive *state; | | 319 | struct signature_archive *state; |
320 | struct archive_entry *my_entry; | | 320 | struct archive_entry *my_entry; |
321 | struct archive *a; | | 321 | struct archive *a; |
322 | char *hash_file, *signature_file; | | 322 | char *hash_file, *signature_file; |
323 | size_t hash_len, signature_len; | | 323 | size_t hash_len, signature_len; |
324 | int r, has_sig; | | 324 | int r, has_sig; |
325 | | | 325 | |
326 | *pkgname = NULL; | | 326 | *pkgname = NULL; |
327 | | | 327 | |
328 | state = xmalloc(sizeof(*state)); | | 328 | state = xcalloc(sizeof(*state), 1); |
329 | state->sign_blocks = NULL; | | | |
330 | state->sign_buf = NULL; | | | |
331 | state->archive = NULL; | | | |
332 | | | 329 | |
333 | r = read_file_from_archive(archive_name, *archive, entry, HASH_FNAME, | | 330 | r = read_file_from_archive(archive_name, *archive, entry, HASH_FNAME, |
334 | &hash_file, &hash_len); | | 331 | &hash_file, &hash_len); |
335 | if (r == -1) { | | 332 | if (r == -1) { |
336 | archive_read_finish(*archive); | | 333 | archive_read_finish(*archive); |
337 | *archive = NULL; | | 334 | *archive = NULL; |
338 | free(state); | | 335 | free(state); |
339 | goto no_valid_signature; | | 336 | goto no_valid_signature; |
340 | } else if (r == 1) { | | 337 | } else if (r == 1) { |
341 | free(state); | | 338 | free(state); |
342 | goto no_valid_signature; | | 339 | goto no_valid_signature; |
343 | } | | 340 | } |
344 | | | 341 | |