Bug 259725 - lang/php74: dns_get_record fails when requested record doesn't exist
Summary: lang/php74: dns_get_record fails when requested record doesn't exist
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Torsten Zuehlsdorff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-09 02:36 UTC by fsbruva
Modified: 2021-12-02 14:36 UTC (History)
3 users (show)

See Also:
fsbruva: maintainer-feedback? (tz)


Attachments
php74 patch (2.82 KB, patch)
2021-11-09 02:41 UTC, fsbruva
no flags Details | Diff
php74 patch (rev2) (3.21 KB, patch)
2021-11-12 20:07 UTC, fsbruva
no flags Details | Diff
php73 patch (3.24 KB, patch)
2021-11-12 20:48 UTC, fsbruva
no flags Details | Diff
php80 patch (3.25 KB, patch)
2021-11-12 20:55 UTC, fsbruva
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description fsbruva 2021-11-09 02:36:18 UTC
This is a resurrection of an old upstream bug report that was never resolved:
https://bugs.php.net/bug.php?id=70027

dns_get_record() allows retrieving one or multiple DNS records of one or multiple types.

However, when multiple DNS records are requested on FreeBSD, the entire function call fails if one of the requested records doesn't exist for the domain. The correct behavior (on other OS's) is to return those record types that do exist. 

Test command:
---------------
php -r "var_dump(dns_get_record('www.google.com', DNS_A + DNS_CNAME));"

Expected result:
----------------
array(1) {
  [0]=>
  array(5) {
    ["host"]=>
    string(14) "www.google.com"
    ["class"]=>
    string(2) "IN"
    ["ttl"]=>
    int(5)
    ["type"]=>
    string(1) "A"
    ["ip"]=>
    string(14) "142.250.73.196"
  }
}

Actual result:
--------------
Warning: dns_get_record(): DNS Query failed in Command line code on line 1
bool(false)

Will submit tested patch shortly - submitting this bug report now so PR# can be referenced in commit.
Comment 1 fsbruva 2021-11-09 02:41:51 UTC
Created attachment 229369 [details]
php74 patch

Patch tested on Freebsd 12.2-RELEASE. Will also submit upstream.
Comment 2 fsbruva 2021-11-09 03:47:46 UTC
This bug also affects php73 and php80. I have tested patches for these also. Should they each get their own bugs? Or include them all here?
Comment 3 Mikael Urankar freebsd_committer freebsd_triage 2021-11-09 10:21:01 UTC
(In reply to fsbruva from comment #2)
include them here.

Don't forget to bump PORTREVISION.
Comment 4 Mikael Urankar freebsd_committer freebsd_triage 2021-11-09 10:22:27 UTC
Have you opened an issue upstream? Do you have a link?
Comment 5 fsbruva 2021-11-12 19:58:13 UTC
(In reply to Mikael Urankar from comment #4)
Upstream bug reported, and I will make a github PR to php-src shortly.
https://bugs.php.net/bug.php?id=81618
Comment 6 fsbruva 2021-11-12 20:07:37 UTC
Created attachment 229454 [details]
php74 patch (rev2)

(In reply to Mikael Urankar from comment #3)
Updated patch to bump PORTREVISION for php74.
Comment 7 fsbruva 2021-11-12 20:48:49 UTC
Created attachment 229455 [details]
php73 patch

Patch for php73
Comment 8 fsbruva 2021-11-12 20:55:18 UTC
Created attachment 229456 [details]
php80 patch
Comment 9 Mikael Urankar freebsd_committer freebsd_triage 2021-11-13 17:01:51 UTC
(In reply to fsbruva from comment #5)
Is it this PR? https://github.com/php/php-src/pull/7650/files
Comment 10 fsbruva 2021-11-14 22:53:37 UTC
(In reply to Mikael Urankar from comment #9)
No - this is the upstream PR. The php.net patching scheme is to merge the PR to the oldest affected branch (7.3 in this case), and the merge it forward as needed. https://github.com/php/php-src/pull/7655/files
Comment 11 fsbruva 2021-11-15 12:29:06 UTC
Upstream PR has been merged to 7.3, 7.4, 8.0 and master.
Comment 12 Torsten Zuehlsdorff freebsd_committer freebsd_triage 2021-11-15 14:52:38 UTC
Thank you for all your work :)

Since it is already in upstream: is there any priority in merging the patches right now into the ports? Or can we just wait for the next release?

Best,
Torsten
Comment 13 fsbruva 2021-11-15 17:36:38 UTC
(In reply to Torsten Zuehlsdorff from comment #12)
No problem, happy to tilt at windmills :)

I suppose the churn of this fix is probably not worth it for most users, but I think waiting for 7.4.27 is too long. Assuming 7.5.26 is released within the next week or so and includes this fix, we can close this bug as OBE.

If for some reason 7.4.26 doesn't include it, then you could add the patch files at the same time as DISTVERSION.

Thoughts?

Matt
Comment 14 Torsten Zuehlsdorff freebsd_committer freebsd_triage 2021-11-15 23:51:10 UTC
Sounds like a good plan. If the next release does not contain the fix, i will add  the patches :)
Comment 15 fsbruva 2021-11-19 00:49:58 UTC
(In reply to Torsten Zuehlsdorff from comment #14)
Welp.... 7.4.26 has been released, and this fix didn't make it in. Do you want me to re-submit my patches against the latest releases? Or try them out and see if there are problems?
Comment 16 Torsten Zuehlsdorff freebsd_committer freebsd_triage 2021-11-20 12:04:41 UTC
I will integrate your patches in the update. I am currently running the build-tests. :)

But i am going to ignore the PHP 7.3 patch. 7.3 is security-only maintenance and even this will end in 15 days. So i don't want to add the patch there.
Comment 17 commit-hook freebsd_committer freebsd_triage 2021-11-20 19:32:21 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=11d48ddebb9c0951afead066cdb578270182010a

commit 11d48ddebb9c0951afead066cdb578270182010a
Author:     Torsten Zuehlsdorff <tz@FreeBSD.org>
AuthorDate: 2021-11-20 19:27:05 +0000
Commit:     Torsten Zuehlsdorff <tz@FreeBSD.org>
CommitDate: 2021-11-20 19:31:39 +0000

    lang/php74: Upgrade from 7.4.25 to 7.4.26

        Core:
            Fixed bug #81518 (Header injection via default_mimetype / default_charset).
        Date:
            Fixed bug #81500 (Interval serialization regression since 7.3.14 / 7.4.2).
        MBString:
            Fixed bug #76167 (mbstring may use pointer from some previous request).
        MySQLi:
            Fixed bug #81494 (Stopped unbuffered query does not throw error).
        PCRE:
            Fixed bug #81424 (PCRE2 10.35 JIT performance regression).
        Streams:
            Fixed bug #54340 (Memory corruption with user_filter).
        XML:
            Fixed bug #79971 (special character is breaking the path in xml function). (CVE-2021-21707)

    Also include a patch to fix issue 259725:
    dns_get_record fails when requested record doesn't exist

    PR:             259725
    Reported by:    fsbruva@yahoo.com
    Sponsored by:   Bounce Experts

 devel/php74-intl/Makefile                          |  1 -
 devel/php74-intl/files/patch-icu70 (gone)          | 38 ----------------------
 lang/php74/Makefile                                |  2 +-
 lang/php74/distinfo                                |  6 ++--
 lang/php74/files/patch-ext_standard_dns.c (new)    | 21 ++++++++++++
 .../files/patch-ext_standard_php__dns.h (new)      | 24 ++++++++++++++
 6 files changed, 49 insertions(+), 43 deletions(-)
Comment 18 commit-hook freebsd_committer freebsd_triage 2021-11-20 19:32:23 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=91fd937f88cae37d468aa1973dd88232c2fb498c

commit 91fd937f88cae37d468aa1973dd88232c2fb498c
Author:     Torsten Zuehlsdorff <tz@FreeBSD.org>
AuthorDate: 2021-11-20 19:29:48 +0000
Commit:     Torsten Zuehlsdorff <tz@FreeBSD.org>
CommitDate: 2021-11-20 19:31:39 +0000

    lang/php80: Upgrade from 8.0.12 to 8.0.13

        Core:
            Fixed bug #81518 (Header injection via default_mimetype / default_charset).
        Date:
            Fixed bug #81500 (Interval serialization regression since 7.3.14 / 7.4.2).
        DBA:
            Fixed bug #81588 (TokyoCabinet driver leaks memory).
        MBString:
            Fixed bug #76167 (mbstring may use pointer from some previous request).
        Opcache:
            Fixed bug #81512 (Unexpected behavior with arrays and JIT).
        PCRE:
            Fixed bug #81424 (PCRE2 10.35 JIT performance regression).
        XML:
            Fixed bug #79971 (special character is breaking the path in xml function). (CVE-2021-21707)
        XMLReader:
            Fixed bug #81521 (XMLReader::getParserProperty may throw with a valid property).

    Also include a patch to fix issue 259725:
    dns_get_record fails when requested record doesn't exist

    PR:             259725
    Reported by:    fsbruva@yahoo.com
    Sponsored by:   Bounce Experts

 devel/php80-intl/Makefile                          |  1 -
 devel/php80-intl/files/patch-icu70 (gone)          | 38 ----------------------
 lang/php80/Makefile                                |  2 +-
 lang/php80/distinfo                                |  6 ++--
 lang/php80/files/patch-ext_standard_dns.c (new)    | 21 ++++++++++++
 .../files/patch-ext_standard_php__dns.h (new)      | 24 ++++++++++++++
 6 files changed, 49 insertions(+), 43 deletions(-)
Comment 19 commit-hook freebsd_committer freebsd_triage 2021-11-20 19:33:24 UTC
A commit in branch 2021Q4 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=4c9d8131c3838f83e3db7c5f7eb072cda9b38837

commit 4c9d8131c3838f83e3db7c5f7eb072cda9b38837
Author:     Torsten Zuehlsdorff <tz@FreeBSD.org>
AuthorDate: 2021-11-20 19:29:48 +0000
Commit:     Torsten Zuehlsdorff <tz@FreeBSD.org>
CommitDate: 2021-11-20 19:32:25 +0000

    lang/php80: Upgrade from 8.0.12 to 8.0.13

        Core:
            Fixed bug #81518 (Header injection via default_mimetype / default_charset).
        Date:
            Fixed bug #81500 (Interval serialization regression since 7.3.14 / 7.4.2).
        DBA:
            Fixed bug #81588 (TokyoCabinet driver leaks memory).
        MBString:
            Fixed bug #76167 (mbstring may use pointer from some previous request).
        Opcache:
            Fixed bug #81512 (Unexpected behavior with arrays and JIT).
        PCRE:
            Fixed bug #81424 (PCRE2 10.35 JIT performance regression).
        XML:
            Fixed bug #79971 (special character is breaking the path in xml function). (CVE-2021-21707)
        XMLReader:
            Fixed bug #81521 (XMLReader::getParserProperty may throw with a valid property).

    Also include a patch to fix issue 259725:
    dns_get_record fails when requested record doesn't exist

    PR:             259725
    Reported by:    fsbruva@yahoo.com
    Sponsored by:   Bounce Experts

    (cherry picked from commit 91fd937f88cae37d468aa1973dd88232c2fb498c)

 lang/php80/Makefile                                |  2 +-
 lang/php80/distinfo                                |  6 +++---
 lang/php80/files/patch-ext_standard_dns.c (new)    | 21 +++++++++++++++++++
 .../files/patch-ext_standard_php__dns.h (new)      | 24 ++++++++++++++++++++++
 4 files changed, 49 insertions(+), 4 deletions(-)
Comment 20 commit-hook freebsd_committer freebsd_triage 2021-11-20 19:33:25 UTC
A commit in branch 2021Q4 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d2b83425d5824041c4d1f609e8a8ebec765e0def

commit d2b83425d5824041c4d1f609e8a8ebec765e0def
Author:     Torsten Zuehlsdorff <tz@FreeBSD.org>
AuthorDate: 2021-11-20 19:27:05 +0000
Commit:     Torsten Zuehlsdorff <tz@FreeBSD.org>
CommitDate: 2021-11-20 19:32:18 +0000

    lang/php74: Upgrade from 7.4.25 to 7.4.26

        Core:
            Fixed bug #81518 (Header injection via default_mimetype / default_charset).
        Date:
            Fixed bug #81500 (Interval serialization regression since 7.3.14 / 7.4.2).
        MBString:
            Fixed bug #76167 (mbstring may use pointer from some previous request).
        MySQLi:
            Fixed bug #81494 (Stopped unbuffered query does not throw error).
        PCRE:
            Fixed bug #81424 (PCRE2 10.35 JIT performance regression).
        Streams:
            Fixed bug #54340 (Memory corruption with user_filter).
        XML:
            Fixed bug #79971 (special character is breaking the path in xml function). (CVE-2021-21707)

    Also include a patch to fix issue 259725:
    dns_get_record fails when requested record doesn't exist

    PR:             259725
    Reported by:    fsbruva@yahoo.com
    Sponsored by:   Bounce Experts

    (cherry picked from commit 11d48ddebb9c0951afead066cdb578270182010a)

 lang/php74/Makefile                                |  2 +-
 lang/php74/distinfo                                |  6 +++---
 lang/php74/files/patch-ext_standard_dns.c (new)    | 21 +++++++++++++++++++
 .../files/patch-ext_standard_php__dns.h (new)      | 24 ++++++++++++++++++++++
 4 files changed, 49 insertions(+), 4 deletions(-)
Comment 21 Torsten Zuehlsdorff freebsd_committer freebsd_triage 2021-11-20 20:04:55 UTC
Comitted! Thank you! :)
Comment 22 fsbruva 2021-12-02 14:36:07 UTC
Looks like my upstream patch made it into 7.4.27RC1, 8.0.14RC1 and 8.1.1RC1. So when those updates get released, the port patch can get dropped.