It looks like this is a problem caused by overeager optimization: gaih_inet() falls back to using the faster _nss_*_gethostbyname2_r when the address family is specified explicitly. This function is incapable of returning scope_id info, so _gethostbyname4_r should be used whenever the NSS module implements it, and there is a possibility that an AF_INET6 address needs to be returned. Patch attached.
Created attachment 5694 [details] Patch to resolve the issue.
I applied the patch with one more change.