/*
- * $Id: rfc1035.c,v 1.14 2000/03/27 21:56:21 wessels Exp $
+ * $Id: rfc1035.c,v 1.15 2000/05/11 22:20:57 wessels Exp $
*
* Low level DNS protocol routines
* AUTHOR: Duane Wessels
unsigned short arcount;
};
+static const char *Alphanum =
+"abcdefghijklmnopqrstuvwxyz"
+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+"0123456789";
+
/*
* rfc1035HeaderPack()
*
return qid;
}
+static void
+rfc1035SetErrno(int n)
+{
+ switch (rfc1035_errno = n) {
+ case 0:
+ rfc1035_error_message = "No error condition";
+ break;
+ case 1:
+ rfc1035_error_message = "Format Error: The name server was "
+ "unable to interpret the query.";
+ break;
+ case 2:
+ rfc1035_error_message = "Server Failure: The name server was "
+ "unable to process this query.";
+ break;
+ case 3:
+ rfc1035_error_message = "Name Error: The domain name does "
+ "not exist.";
+ break;
+ case 4:
+ rfc1035_error_message = "Not Implemented: The name server does "
+ "not support the requested kind of query.";
+ break;
+ case 5:
+ rfc1035_error_message = "Refused: The name server refuses to "
+ "perform the specified operation.";
+ break;
+ default:
+ rfc1035_error_message = "Unknown Error";
+ break;
+ }
+}
+
void
rfc1035RRDestroy(rfc1035_rr * rr, int n)
{
rfc1035_errno = 0;
rfc1035_error_message = NULL;
if (hdr.rcode) {
- rfc1035_errno = (int) hdr.rcode;
- switch (rfc1035_errno) {
- case 0:
- rfc1035_error_message = "No error condition";
- break;
- case 1:
- rfc1035_error_message = "Format Error: The name server was "
- "unable to interpret the query.";
- break;
- case 2:
- rfc1035_error_message = "Server Failure: The name server was "
- "unable to process this query.";
- break;
- case 3:
- rfc1035_error_message = "Name Error: The domain name does "
- "not exist.";
- break;
- case 4:
- rfc1035_error_message = "Not Implemented: The name server does "
- "not support the requested kind of query.";
- break;
- case 5:
- rfc1035_error_message = "Refused: The name server refuses to "
- "perform the specified operation.";
- break;
- default:
- rfc1035_error_message = "Unknown Error";
- break;
- }
+ rfc1035SetErrno((int) hdr.rcode);
return -rfc1035_errno;
}
i = (int) hdr.qdcount;
off_t offset = 0;
size_t sz = *szp;
memset(&h, '\0', sizeof(h));
+ /* the first char of hostname must be alphanmeric */
+ if (NULL == strchr(Alphanum, *buf)) {
+ rfc1035SetErrno(3);
+ return 0;
+ }
h.id = rfc1035Qid();
h.qr = 0;
h.rd = 1;
/*
- * $Id: dns_internal.cc,v 1.23 2000/05/11 03:05:24 wessels Exp $
+ * $Id: dns_internal.cc,v 1.24 2000/05/11 22:21:01 wessels Exp $
*
* DEBUG: section 78 DNS lookups; interacts with lib/rfc1035.c
* AUTHOR: Duane Wessels
idns_query *q = memAllocate(MEM_IDNS_QUERY);
q->sz = sizeof(q->buf);
q->id = rfc1035BuildAQuery(name, q->buf, &q->sz);
+ if (0 == q->id) {
+ /* problem with query data -- query not sent */
+ callback(data, NULL, 0);
+ memFree(q, MEM_IDNS_QUERY);
+ return;
+ }
debug(78, 3) ("idnsALookup: buf is %d bytes for %s, id = %#hx\n",
(int) q->sz, name, q->id);
q->callback = callback;