pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/pkg_install-renovation]: pkgsrc/pkgtools/pkg_install/files pkg_instal...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/eea63a42203c
branches:  pkg_install-renovation
changeset: 541608:eea63a42203c
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Thu Nov 27 19:24:13 2008 +0000

description:
pkg_install-20081127:
Correctly deal with short reads from fetchIO_read when loading
pkg-vulnerabilities.

diffstat:

 pkgtools/pkg_install/files/admin/audit.c |  25 ++++++++++++++++++-------
 pkgtools/pkg_install/files/lib/version.h |   4 ++--
 2 files changed, 20 insertions(+), 9 deletions(-)

diffs (71 lines):

diff -r 63a3b0e0925a -r eea63a42203c pkgtools/pkg_install/files/admin/audit.c
--- a/pkgtools/pkg_install/files/admin/audit.c  Wed Oct 29 10:38:53 2008 +0000
+++ b/pkgtools/pkg_install/files/admin/audit.c  Thu Nov 27 19:24:13 2008 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audit.c,v 1.8.2.5 2008/10/02 20:51:41 joerg Exp $      */
+/*     $NetBSD: audit.c,v 1.8.2.6 2008/11/27 19:24:13 joerg Exp $      */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -8,7 +8,7 @@
 #include <sys/cdefs.h>
 #endif
 #ifndef lint
-__RCSID("$NetBSD: audit.c,v 1.8.2.5 2008/10/02 20:51:41 joerg Exp $");
+__RCSID("$NetBSD: audit.c,v 1.8.2.6 2008/11/27 19:24:13 joerg Exp $");
 #endif
 
 /*-
@@ -343,7 +343,8 @@
 {
        struct pkg_vulnerabilities *pv_check;
        char *buf, *decompressed_input;
-       size_t buf_len, decompressed_len;
+       size_t buf_len, buf_fetched, decompressed_len;
+       ssize_t cur_fetched;
        struct url_stat st;
        fetchIO *f;
        int fd;
@@ -365,11 +366,21 @@
 
        buf_len = st.size;
        buf = xmalloc(buf_len + 1);
+       buf_fetched = 0;
 
-       if (fetchIO_read(f, buf, buf_len) != buf_len)
-               errx(EXIT_FAILURE,
-                   "Failure during fetch of pkg-vulnerabilities: %s",
-                   fetchLastErrString);
+       while (buf_fetched < buf_len) {
+               cur_fetched = fetchIO_read(f, buf + buf_fetched,
+                   buf_len - buf_fetched);
+               if (cur_fetched == 0)
+                       errx(EXIT_FAILURE,
+                           "Truncated pkg-vulnerabilities received");
+               else if (cur_fetched == -1)
+                       errx(EXIT_FAILURE,
+                           "IO error while fetching pkg-vulnerabilities: %s",
+                           fetchLastErrString);
+               buf_fetched += cur_fetched;
+       }
+       
        buf[buf_len] = '\0';
 
        if (decompress_buffer(buf, buf_len, &decompressed_input,
diff -r 63a3b0e0925a -r eea63a42203c pkgtools/pkg_install/files/lib/version.h
--- a/pkgtools/pkg_install/files/lib/version.h  Wed Oct 29 10:38:53 2008 +0000
+++ b/pkgtools/pkg_install/files/lib/version.h  Thu Nov 27 19:24:13 2008 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: version.h,v 1.102.2.17 2008/10/02 20:51:41 joerg Exp $ */
+/*     $NetBSD: version.h,v 1.102.2.18 2008/11/27 19:24:13 joerg Exp $ */
 
 /*
  * Copyright (c) 2001 Thomas Klausner.  All rights reserved.
@@ -27,6 +27,6 @@
 #ifndef _INST_LIB_VERSION_H_
 #define _INST_LIB_VERSION_H_
 
-#define PKGTOOLS_VERSION "20081003"
+#define PKGTOOLS_VERSION "20081127"
 
 #endif /* _INST_LIB_VERSION_H_ */



Home | Main Index | Thread Index | Old Index