| 907 | */ |
| 908 | |
| 909 | const char * /* O - Resolved hostname or @code NULL@ */ |
| 910 | httpResolveHostname(http_t *http, /* I - HTTP connection */ |
| 911 | char *buffer, /* I - Hostname buffer */ |
| 912 | size_t bufsize) /* I - Size of buffer */ |
| 913 | { |
| 914 | if (!http) |
| 915 | return (NULL); |
| 916 | |
| 917 | if (isdigit(http->hostname[0] & 255) || http->hostname[0] == '[') |
| 918 | { |
| 919 | char temp[1024]; /* Temporary string */ |
| 920 | |
| 921 | if (httpAddrLookup(http->hostaddr, temp, sizeof(temp))) |
| 922 | strlcpy(http->hostname, temp, sizeof(http->hostname)); |
| 923 | else |
| 924 | return (NULL); |
| 925 | } |
| 926 | |
| 927 | if (buffer) |
| 928 | { |
| 929 | if (http->hostname[0] == '/') |
| 930 | strlcpy(buffer, "localhost", bufsize); |
| 931 | else |
| 932 | strlcpy(buffer, http->hostname, bufsize); |
| 933 | |
| 934 | return (buffer); |
| 935 | } |
| 936 | else if (http->hostname[0] == '/') |
| 937 | return ("localhost"); |
| 938 | else |
| 939 | return (http->hostname); |
| 940 | } |
no test coverage detected