diff options
author | 2013-04-10 22:16:45 +0000 | |
---|---|---|
committer | 2013-04-10 22:16:45 +0000 | |
commit | 3869a299b8716404bc55d000677852b52cef54ef (patch) | |
tree | 7531e874bc4924cfc47dea2aaca70522e03274cb /paxinc.c | |
parent | pspax: fix signed compare warning gcc throws up (diff) | |
download | pax-utils-3869a299b8716404bc55d000677852b52cef54ef.tar.gz pax-utils-3869a299b8716404bc55d000677852b52cef54ef.tar.bz2 pax-utils-3869a299b8716404bc55d000677852b52cef54ef.zip |
ar_next: fix signed warnings from gcc, and clean up memory when closing archives
Diffstat (limited to 'paxinc.c')
-rw-r--r-- | paxinc.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -1,7 +1,7 @@ /* * Copyright 2003-2012 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxinc.c,v 1.15 2012/11/04 07:26:24 vapier Exp $ + * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxinc.c,v 1.16 2013/04/10 22:16:45 vapier Exp $ * * Copyright 2005-2012 Ned Ludd - <solar@gentoo.org> * Copyright 2005-2012 Mike Frysinger - <vapier@gentoo.org> @@ -53,12 +53,15 @@ archive_handle *ar_open(const char *filename) archive_member *ar_next(archive_handle *ar) { char *s; - size_t len = 0; + ssize_t len = 0; static archive_member ret; if (ar->skip && lseek(ar->fd, ar->skip, SEEK_CUR) == -1) { close_and_ret: + free(ar->extfn); close(ar->fd); + ar->extfn = NULL; + ar->fd = -1; return NULL; } @@ -84,7 +87,6 @@ close_and_ret: goto close_and_ret; } len = atoi(ret.buf.formatted.size); - /* we will leak this memory */ ar->extfn = xmalloc(sizeof(char) * (len + 1)); if (read(ar->fd, ar->extfn, len) != len) goto close_and_ret; @@ -100,7 +102,7 @@ close_and_ret: if (s[0] == '#' && s[1] == '1' && s[2] == '/') { /* BSD extended filename, always in use on Darwin */ len = atoi(s + 3); - if (len <= sizeof(ret.buf.formatted.name)) { + if (len <= (ssize_t)sizeof(ret.buf.formatted.name)) { if (read(ar->fd, ret.buf.formatted.name, len) != len) goto close_and_ret; } else { |