Bug 2039854

Summary: getaddrinfo for empty hostname returns unexpected error
Product: [Fedora] Fedora Reporter: Tom Deseyn <tdeseyn>
Component: systemdAssignee: systemd-maint
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 36CC: fedoraproject, filbranden, flepied, lnykryn, msekleta, omajid, ryncsn, ssahani, s, systemd-maint, yuwatana, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: systemd-249.11-1.fc35 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-04-10 19:52:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tom Deseyn 2022-01-12 14:43:26 UTC
Description of problem:

Calling getaddrinfo for an empty hostname returns an unexpected error.

Version-Release number of selected component (if applicable):

Fedora Rawhide

Steps to Reproduce:

```
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <stdio.h>

int main() {
   struct addrinfo* info;
   struct addrinfo hint;
   memset(&hint, 0, sizeof(struct addrinfo));
   hint.ai_flags = AI_CANONNAME;
   hint.ai_family = AF_INET;

   int result = getaddrinfo("", NULL, &hint, &info);
   if (result != 0) {
     fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(result));
   }
   return result;
}
```

Actual results:

```
result is 253: getaddrinfo: Temporary failure in name resolution
```

Expected results:

```
result is 254: getaddrinfo: Name or service not known
```

Comment 1 Tom Deseyn 2022-01-20 15:44:46 UTC
Can someone please take a look at this issue?

I've assigned it to systemd, but the cause may be elsewhere in the name resolution.

The issue causes a .NET test (https://github.com/dotnet/runtime/) to fail on Rawhide.

Thanks, Tom

Comment 2 Yu Watanabe 2022-01-20 18:21:12 UTC
I created a PR for this issue in upstream: https://github.com/systemd/systemd/pull/22197

Comment 3 Yu Watanabe 2022-01-23 21:49:51 UTC
The previous PR is already merged, but will be replaced by https://github.com/systemd/systemd/pull/22231

Comment 4 Tom Deseyn 2022-02-07 12:18:52 UTC
Thanks for fixing the issue.

Since last week, the issue is also appearing in our Fedora 35 CI VM. Previously it was only on Rawhide.

Comment 5 Ben Cotton 2022-02-08 20:09:21 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 36 development cycle.
Changing version to 36.

Comment 6 Fedora Update System 2022-04-06 20:26:55 UTC
FEDORA-2022-423231bb82 has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2022-423231bb82

Comment 7 Fedora Update System 2022-04-07 16:01:01 UTC
FEDORA-2022-423231bb82 has been pushed to the Fedora 35 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-423231bb82`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-423231bb82

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 8 Fedora Update System 2022-04-10 19:52:33 UTC
FEDORA-2022-423231bb82 has been pushed to the Fedora 35 stable repository.
If problem still persists, please make note of it in this bug report.