3 ms·
In glibc's libresolv, this is caused by res_hnok in resolv/res_name.c returning 0: /* * Verify that a domain name uses an acceptable character set.
by gue5t 12y ago
In glibc's libresolv, this is caused by res_hnok in resolv/res_name.c returning 0:
/*
* Verify that a domain name uses an acceptable character set.
*/
/*
* Note the conspicuous absence of ctype macros in these definitions. On
* non-ASCII hosts, we can't depend on string literals or ctype macros to
* tell us anything about network-format data. The rest of the BIND system
* is not careful about this, but for some reason, we're doing it right here.
*/
#define PERIOD 0x2e
#define hyphenchar(c) ((c) == 0x2d)
#define underscorechar(c) ((c) == 0x5f)
#define bslashchar(c) ((c) == 0x5c)
#define periodchar(c) ((c) == PERIOD)
#define asterchar(c) ((c) == 0x2a)
#define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \
|| ((c) >= 0x61 && (c) <= 0x7a))
#define digitchar(c) ((c) >= 0x30 && (c) <= 0x39)
#define borderchar(c) (alphachar(c) || digitchar(c))
#define middlechar(c) (borderchar(c) || hyphenchar(c) || underscorechar(c))
#define domainchar(c) ((c) > 0x20 && (c) < 0x7f)
int
res_hnok(const char *dn) {
int pch = PERIOD, ch = *dn++;
while (ch != '\0') {
int nch = *dn++;
if (periodchar(ch)) {
(void)NULL;
} else if (periodchar(pch)) {
if (!borderchar(ch))
return (0);
} else if (periodchar(nch) || nch == '\0') {
if (!borderchar(ch))
return (0);
} else {
if (!middlechar(ch))
return (0);
}
pch = ch, ch = nch;
}
return (1);
}
- gue5t 12y agoAnd the hack fix: /* hnokpre.c: LD_PRELOAD shim to bypass valid hostname checking in glibc gcc -fPIC -shared hnokpre.c -o libhnokpre.so LD_PRELOAD=./libhnokpre.so curl http://mattias-.github.io/ */ int res_hnok(const char* dn) { return 1; } int __res_hnok(const char* dn) { return 1; }
- poizan42 12y agoI'm kinda wondering what's the reason for that that check to begin with. Just being pedantic for pedentrys sake?
- deleted 12y ago[deleted]
- poizan42 12y ago* Note the conspicuous absence of ctype macros in these definitions. On * non-ASCII hosts, we can't depend on string literals or ctype macros to * tell us anything about network-format data. The rest of the BIND system * is not careful about this, but for some reason, we're doing it right here. Well that is only a problem if the charset is converted to something else. Are there still systems out there without a C compiler that can be told to use ASCII?