LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-02-2010, 07:07 PM   #1
btp10
LQ Newbie
 
Registered: Mar 2010
Posts: 4

Rep: Reputation: 0
Exclamation Error message of dn_expand


Hi,
Can anyone tell me what "Message too long" error returned by the function dn_expand means?

The function call I used is as follows:

dn_expand(poutput, poutput + output_space_used, *out_rr, output_qname, 255);

I assumed that the error was due to the difference between the 1st argument and 2nd argument, However, changing the difference to the accepted dns message size (512 bytes) or even to no difference at all did nothing to remove the error.

Further, I am trying to check the output after having first compressed a domain name using dn_comp into *out_rr. This function call is in order to check whether the compression is happening correctly.

Any ideas on what I might be doing wrong ?
 
Old 04-03-2010, 12:14 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by btp10 View Post
Hi,
Can anyone tell me what "Message too long" error returned by the function dn_expand means?

The function call I used is as follows:

dn_expand(poutput, poutput + output_space_used, *out_rr, output_qname, 255);

I assumed that the error was due to the difference between the 1st argument and 2nd argument, However, changing the difference to the accepted dns message size (512 bytes) or even to no difference at all did nothing to remove the error.

Further, I am trying to check the output after having first compressed a domain name using dn_comp into *out_rr. This function call is in order to check whether the compression is happening correctly.

Any ideas on what I might be doing wrong ?
And why haven't you looked yet into the function source ?
 
0 members found this post helpful.
Old 04-04-2010, 07:57 AM   #3
btp10
LQ Newbie
 
Registered: Mar 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Sergei Steshenko View Post
And why haven't you looked yet into the function source ?
I have looked into the function source and I could not figure out anything from that as there are too many flags that I do not understand. Moreover, the source was pretty difficult to find so that when I did find the code I wasn't sure whether it was for the actual function that I am using or the source code for some other version of the function.

PS: I don't know whether you realize it or not but your response is ---- 1. Rude, 2. Not helpful at all. Thanks a lot anyways.
 
Old 04-04-2010, 09:23 AM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by btp10 View Post
I have looked into the function source and I could not figure out anything from that as there are too many flags that I do not understand. Moreover, the source was pretty difficult to find so that when I did find the code I wasn't sure whether it was for the actual function that I am using or the source code for some other version of the function.

PS: I don't know whether you realize it or not but your response is ---- 1. Rude, 2. Not helpful at all. Thanks a lot anyways.
So, now copy the source into your program, changing the function name, and adding 'printf' statements, so you'll be able to trace which statements are executed and why you are getting the error message.

The above is trivial.

The source apparently is in 'glibc' - at least, this is where I find it.


The sources:

Code:
int
dn_expand(const u_char *msg, const u_char *eom, const u_char *src,
          char *dst, int dstsiz)
{
        int n = ns_name_uncompress(msg, eom, src, dst, (size_t)dstsiz);

        if (n > 0 && dst[0] == '.')
                dst[0] = '\0';
        return (n);
}

Code:
int
ns_name_uncompress(const u_char *msg, const u_char *eom, const u_char *src,
                   char *dst, size_t dstsiz)
{
        u_char tmp[NS_MAXCDNAME];
        int n;

        if ((n = ns_name_unpack(msg, eom, src, tmp, sizeof tmp)) == -1)
                return (-1);
        if (ns_name_ntop(tmp, dst, dstsiz) == -1)
                return (-1);
        return (n);
}
Code:
int
ns_name_ntop(const u_char *src, char *dst, size_t dstsiz)
{
	const u_char *cp;
	char *dn, *eom;
	u_char c;
	u_int n;
	int l;

	cp = src;
	dn = dst;
	eom = dst + dstsiz;

	while ((n = *cp++) != 0) {
		if ((n & NS_CMPRSFLGS) == NS_CMPRSFLGS) {
			/* Some kind of compression pointer. */
			__set_errno (EMSGSIZE);
			return (-1);
		}
		if (dn != dst) {
			if (dn >= eom) {
				__set_errno (EMSGSIZE);
				return (-1);
			}
			*dn++ = '.';
		}
		if ((l = labellen(cp - 1)) < 0) {
			__set_errno (EMSGSIZE);
			return(-1);
		}
		if (dn + l >= eom) {
			__set_errno (EMSGSIZE);
			return (-1);
		}
		if ((n & NS_CMPRSFLGS) == NS_TYPE_ELT) {
			int m;

			if (n != DNS_LABELTYPE_BITSTRING) {
				/* XXX: labellen should reject this case */
				__set_errno (EINVAL);
				return(-1);
			}
			if ((m = decode_bitstring(&cp, dn, eom)) < 0)
			{
				__set_errno (EMSGSIZE);
				return(-1);
			}
			dn += m;
			continue;
		}
		for ((void)NULL; l > 0; l--) {
			c = *cp++;
			if (special(c)) {
				if (dn + 1 >= eom) {
					__set_errno (EMSGSIZE);
					return (-1);
				}
				*dn++ = '\\';
				*dn++ = (char)c;
			} else if (!printable(c)) {
				if (dn + 3 >= eom) {
					__set_errno (EMSGSIZE);
					return (-1);
				}
				*dn++ = '\\';
				*dn++ = digits[c / 100];
				*dn++ = digits[(c % 100) / 10];
				*dn++ = digits[c % 10];
			} else {
				if (dn >= eom) {
					__set_errno (EMSGSIZE);
					return (-1);
				}
				*dn++ = (char)c;
			}
		}
	}
	if (dn == dst) {
		if (dn >= eom) {
			__set_errno (EMSGSIZE);
			return (-1);
		}
		*dn++ = '.';
	}
	if (dn >= eom) {
		__set_errno (EMSGSIZE);
		return (-1);
	}
	*dn++ = '\0';
	return (dn - dst);
}

Code:
int
ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src,
	       u_char *dst, size_t dstsiz)
{
	const u_char *srcp, *dstlim;
	u_char *dstp;
	int n, len, checked, l;

	len = -1;
	checked = 0;
	dstp = dst;
	srcp = src;
	dstlim = dst + dstsiz;
	if (srcp < msg || srcp >= eom) {
		__set_errno (EMSGSIZE);
		return (-1);
	}
	/* Fetch next label in domain name. */
	while ((n = *srcp++) != 0) {
		/* Check for indirection. */
		switch (n & NS_CMPRSFLGS) {
		case 0:
		case NS_TYPE_ELT:
			/* Limit checks. */
			if ((l = labellen(srcp - 1)) < 0) {
				__set_errno (EMSGSIZE);
				return(-1);
			}
			if (dstp + l + 1 >= dstlim || srcp + l >= eom) {
				__set_errno (EMSGSIZE);
				return (-1);
			}
			checked += l + 1;
			*dstp++ = n;
			memcpy(dstp, srcp, l);
			dstp += l;
			srcp += l;
			break;

		case NS_CMPRSFLGS:
			if (srcp >= eom) {
				__set_errno (EMSGSIZE);
				return (-1);
			}
			if (len < 0)
				len = srcp - src + 1;
			srcp = msg + (((n & 0x3f) << 8) | (*srcp & 0xff));
			if (srcp < msg || srcp >= eom) {  /*%< Out of range. */
				__set_errno (EMSGSIZE);
				return (-1);
			}
			checked += 2;
			/*
			 * Check for loops in the compressed name;
			 * if we've looked at the whole message,
			 * there must be a loop.
			 */
			if (checked >= eom - msg) {
				__set_errno (EMSGSIZE);
				return (-1);
			}
			break;

		default:
			__set_errno (EMSGSIZE);
			return (-1);			/*%< flag error */
		}
	}
	*dstp = '\0';
	if (len < 0)
		len = srcp - src;
	return (len);
}
The code snippets above have a lot of

Code:
__set_errno (EMSGSIZE)
and putting a unique print statement just before each of them is trivial.

About my response - do you realize you are plain lazy and want others to do your job ?
 
0 members found this post helpful.
Old 04-04-2010, 05:05 PM   #5
btp10
LQ Newbie
 
Registered: Mar 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
About my response - do you realize you are plain lazy and want others to do your job ?
1. By not asking for help again after replying to you, I think it was very clear that the thread was "CLOSED" at least for "you".

2. I have completed my work - ALL ON MY OWN.

3. When I posted the thread, all I wanted to know was whether anyone had any idea about dn_expand(). I wasn't expecting anyone to do my work for me. If you have such trouble replying, just don't bother to.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MPlayer Error Message - Error Opening/Initializing Video Out Device Harpo Linux - Newbie 12 12-29-2009 11:26 PM
CD/DVD Creator shows an error message SAO error:unpredictable track size sarkhelmriganka Fedora 0 07-18-2009 04:50 AM
Strange Repeating Error message in /var/log/message lucktsm Linux - Security 2 10-27-2006 08:29 AM
Error message received from system Error while reading filter description for true Steel_J Linux - Software 2 03-04-2006 06:10 PM
QMAIL error:554 Transaction failed: message format error mpk25 Linux - Software 1 10-15-2004 12:53 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration