View | Details | Raw Unified | Return to bug 263924 | Differences between
and this patch

Collapse All | Expand All

(-)b/dns/pear-Net_DNS2/Makefile (-1 / +6 lines)
Lines 1-7 Link Here
1
# Created by: Wen Heping <wen@FreeBSD.org>
1
# Created by: Wen Heping <wen@FreeBSD.org>
2
2
3
PORTNAME=	Net_DNS2
3
PORTNAME=	Net_DNS2
4
PORTVERSION=	1.5.0
4
PORTVERSION=	1.5.2
5
DISTVERSIONPREFIX=	v
5
CATEGORIES=	dns net pear
6
CATEGORIES=	dns net pear
6
7
7
MAINTAINER=	sunpoet@FreeBSD.org
8
MAINTAINER=	sunpoet@FreeBSD.org
Lines 12-17 LICENSE_FILE= ${WRKSRC}/LICENSE Link Here
12
13
13
USES=		pear
14
USES=		pear
14
15
16
USE_GITHUB=	yes
17
GH_ACCOUNT=	mikepultz
18
GH_PROJECT=	netdns2
19
15
NO_ARCH=	yes
20
NO_ARCH=	yes
16
21
17
.include <bsd.port.mk>
22
.include <bsd.port.mk>
(-)b/dns/pear-Net_DNS2/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1620438069
1
TIMESTAMP = 1652279368
2
SHA256 (PEAR/Net_DNS2-1.5.0.tgz) = 6b2157757aa7d388694ffb3e224da63580e7a3382b6473b3e51ad4d8f2dde3ff
2
SHA256 (PEAR/mikepultz-netdns2-v1.5.2_GH0.tar.gz) = a1cada39b33afbbc8f0d9b998068485d85acb73a4c8c1681aab009604680a1ce
3
SIZE (PEAR/Net_DNS2-1.5.0.tgz) = 81188
3
SIZE (PEAR/mikepultz-netdns2-v1.5.2_GH0.tar.gz) = 83947
(-)b/dns/pear-Net_DNS2/files/patch-Net_DNS2_Cache_File.php (+87 lines)
Added Link Here
1
--- Net/DNS2/Cache/File.php.orig	2020-10-11 17:33:54 UTC
2
+++ Net/DNS2/Cache/File.php
3
@@ -44,10 +44,17 @@ class Net_DNS2_Cache_File extends Net_DNS2_Cache
4
         //
5
         // check that the file exists first
6
         //
7
-        if ( ($this->cache_opened == false) 
8
-            && (file_exists($this->cache_file) == true) 
9
-            && (filesize($this->cache_file) > 0)
10
-        ) {
11
+        if ( ($this->cache_opened == false) && (file_exists($this->cache_file) == true) ) {
12
+
13
+            //   
14
+            // check the file size                
15
+            //                   
16
+            $file_size = filesize($this->cache_file);
17
+            if ( ($file_size === false) || ($file_size <= 0) ) {
18
+
19
+                return;
20
+            }
21
+
22
             //
23
             // open the file for reading
24
             //
25
@@ -62,7 +69,7 @@ class Net_DNS2_Cache_File extends Net_DNS2_Cache
26
                 //
27
                 // read the file contents
28
                 //
29
-                $data = fread($fp, filesize($this->cache_file));
30
+                $data = fread($fp, $file_size);
31
 
32
                 $decoded = null;
33
                     
34
@@ -137,29 +144,39 @@ class Net_DNS2_Cache_File extends Net_DNS2_Cache
35
             fseek($fp, 0, SEEK_SET);
36
 
37
             //
38
-            // read the file contents
39
-            //
40
-            $data = @fread($fp, filesize($this->cache_file));
41
-            if ( ($data !== false) && (strlen($data) > 0) ) {
42
+            // get the file size first; in PHP 8.0 fread() was changed to throw an exception if you try
43
+            // and read 0 bytes from a file.
44
+            //         
45
+            $file_size = @filesize($this->cache_file);
46
 
47
+            if ( ($file_size !== false) && ($file_size > 0) ) {
48
+
49
                 //
50
-                // unserialize and store the data
51
+                // read the file contents
52
                 //
53
-                $c = $this->cache_data;
54
+                $data = @fread($fp, $file_size);
55
+                
56
+                if ( ($data !== false) && (strlen($data) > 0) ) {
57
 
58
-                $decoded = null;
59
+                    //
60
+                    // unserialize and store the data
61
+                    //
62
+                    $c = $this->cache_data;
63
 
64
-                if ($this->cache_serializer == 'json') {
65
+                    $decoded = null;
66
 
67
-                    $decoded = json_decode($data, true);
68
-                } else {
69
+                    if ($this->cache_serializer == 'json') {
70
 
71
-                    $decoded = unserialize($data);
72
-                }
73
+                        $decoded = json_decode($data, true);
74
+                    } else {
75
+
76
+                        $decoded = unserialize($data);
77
+                    }
78
                 
79
-                if (is_array($decoded) == true) {
80
+                    if (is_array($decoded) == true) {
81
 
82
-                    $this->cache_data = array_merge($c, $decoded);
83
+                        $this->cache_data = array_merge($c, $decoded);
84
+                    }
85
                 }
86
             }
87
 
(-)b/dns/pear-Net_DNS2/files/patch-Net_DNS2_Cache_Shm.php (-1 / +16 lines)
Added Link Here
0
- 
1
--- Net/DNS2/Cache/Shm.php.orig	2020-10-11 17:33:54 UTC
2
+++ Net/DNS2/Cache/Shm.php
3
@@ -254,7 +254,12 @@ class Net_DNS2_Cache_Shm extends Net_DNS2_Cache
4
             //
5
             // close the segment
6
             //
7
-            shmop_close($this->_cache_id);
8
+            // shmop_close() is deprecated in v8.0.0
9
+            //
10
+            if (version_compare(PHP_VERSION, '8.0.0', '<') == true)
11
+            {
12
+                shmop_close($this->_cache_id);
13
+            }
14
 
15
             //
16
             // unlock

Return to bug 263924