public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-projects commit in pax-utils: paxinc.c
@ 2009-03-15  8:53 Mike Frysinger (vapier)
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger (vapier) @ 2009-03-15  8:53 UTC (permalink / raw
  To: gentoo-commits

vapier      09/03/15 08:53:00

  Modified:             paxinc.c
  Log:
  check return value of read() since gcc whines about it now

Revision  Changes    Path
1.13                 pax-utils/paxinc.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/paxinc.c?rev=1.13&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/paxinc.c?rev=1.13&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/paxinc.c?r1=1.12&r2=1.13

Index: paxinc.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/paxinc.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- paxinc.c	30 Dec 2008 13:34:46 -0000	1.12
+++ paxinc.c	15 Mar 2009 08:52:59 -0000	1.13
@@ -1,7 +1,7 @@
 /*
  * Copyright 2003-2007 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxinc.c,v 1.12 2008/12/30 13:34:46 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxinc.c,v 1.13 2009/03/15 08:52:59 vapier Exp $
  *
  * Copyright 2005-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2007 Mike Frysinger  - <vapier@gentoo.org>
@@ -69,7 +69,8 @@
 	 * '\n' is used for padding */
 	if (ret.buf.raw[0] == '\n') {
 		memmove(ret.buf.raw, ret.buf.raw+1, 59);
-		read(ar->fd, ret.buf.raw+59, 1);
+		if (read(ar->fd, ret.buf.raw+59, 1) != 1)
+			goto close_and_ret;
 	}
 
 	if ((ret.buf.formatted.magic[0] != '`') || (ret.buf.formatted.magic[1] != '\n')) {






^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: paxinc.c
@ 2013-04-10 22:16 Mike Frysinger (vapier)
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-10 22:16 UTC (permalink / raw
  To: gentoo-commits

vapier      13/04/10 22:16:45

  Modified:             paxinc.c
  Log:
  ar_next: fix signed warnings from gcc, and clean up memory when closing archives

Revision  Changes    Path
1.16                 pax-utils/paxinc.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/paxinc.c?rev=1.16&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/paxinc.c?rev=1.16&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/paxinc.c?r1=1.15&r2=1.16

Index: paxinc.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/paxinc.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- paxinc.c	4 Nov 2012 07:26:24 -0000	1.15
+++ paxinc.c	10 Apr 2013 22:16:45 -0000	1.16
@@ -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_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 @@
 			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 @@
 	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 {





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-04-10 22:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-15  8:53 [gentoo-commits] gentoo-projects commit in pax-utils: paxinc.c Mike Frysinger (vapier)
  -- strict thread matches above, loose matches on Subject: below --
2013-04-10 22:16 Mike Frysinger (vapier)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox