head	1.2;
access;
symbols
	RELEASE_5_EOL:1.1
	RELEASE_7_0_0:1.1
	RELEASE_6_3_0:1.1
	PRE_XORG_7:1.1
	RELEASE_4_EOL:1.1
	RELEASE_6_2_0:1.1
	RELEASE_6_1_0:1.1
	RELEASE_5_5_0:1.1
	RELEASE_6_0_0:1.1
	RELEASE_5_4_0:1.1
	RELEASE_4_11_0:1.1
	RELEASE_5_3_0:1.1
	RELEASE_4_10_0:1.1
	RELEASE_5_2_1:1.1
	RELEASE_5_2_0:1.1
	RELEASE_4_9_0:1.1
	RELEASE_5_1_0:1.1
	RELEASE_4_8_0:1.1
	RELEASE_5_0_0:1.1
	RELEASE_4_7_0:1.1;
locks; strict;
comment	@# @;


1.2
date	2008.08.03.03.18.25;	author ache;	state dead;
branches;
next	1.1;

1.1
date	2002.05.31.10.12.21;	author ache;	state Exp;
branches;
next	;


desc
@@


1.2
log
@Update to 3.0
@
text
@--- zipfile.c.orig	Sun Nov  7 13:30:11 1999
+++ zipfile.c	Fri May 31 13:58:36 2002
@@@@ -14,6 +14,10 @@@@
 #include "zip.h"
 #include "revision.h"
 
+#ifdef __FreeBSD__
+#include <sys/param.h>
+#endif
+
 #ifdef VMS
 #  include <rms.h>
 #  include <starlet.h>
@@@@ -628,6 +632,18 @@@@
 
 #endif /* !UTIL */
 
+#ifdef __FreeBSD__
+#if __FreeBSD_version < 500028
+local off_t fsize(FILE *f) {
+    struct stat s;
+
+    if (f == NULL) return 0;
+    if (fstat(fileno(f), &s) < 0) return 0;
+    return s.st_size;
+}
+#endif
+#endif
+
 /*
  * scanzipf_reg starts searching for the End Signature at the end of the file
  * The End Signature points to the Central Directory Signature which points
@@@@ -667,7 +683,13 @@@@
     t[1] = '\0';
     t[2] = '\0';
     t[3] = '\0';
-    if (fseek(f, -4096L, SEEK_END) == 0) {
+    if (
+#ifdef __FreeBSD__
+#if __FreeBSD_version < 500028
+	fsize(f) >= 4096L &&
+#endif
+#endif
+	fseek(f, -4096L, SEEK_END) == 0) {
       zipbeg = (ulg) (ftell(f) + 4096L);
       while (!found && zipbeg >= 4096) {
         zipbeg -= 4096L;
@@@@ -678,6 +700,11 @@@@
  * XXX error check ??
  */
         fread(buf, 1, 4096, f);
+#ifdef __FreeBSD__
+#if __FreeBSD_version < 500028
+	if (ftell(f) >= 8192L)
+#endif
+#endif
         fseek(f, -8192L, SEEK_CUR);
         t = &buf[4095];
 /*
@


1.1
log
@Prevent negative fseek for old FreeBSD versions

PR:		33170
Submitted by:	"Vadim Mikhailov" <mvp@@braz.ru> (partially)
@
text
@@

