Stan Ubuni writes:

Regardless, in rfc1035/rfc1035reply.c, lines 128 and 129 read:

        r->ra=(p[3] >> 7) & 1;
        r->rcode=p[3] & 15;

While I do believe these two lines should read as:

        r->ra=(((unsigned char)p[3]) >> 7) & 1;
        r->rcode=((unsigned char)p[3]) & 15;

Perhaps Mr. White can try this fix and let us know if it works or not.

I anxiously await your arrogant/elitist repsonse.

Here's my arrogant/elitist response:

I challenge you to come up with any possible value for p[3] for which the above two code fragments will yield different results.

It shouldn't be too hard to write a simple loop that tries all 256 possible values, casts it alternatively to "char" & "unsigned char", then sees whether the results differ, in the expressions above.

Here, I'll even write the code for you:

#include <stdio.h>

void main()
{
        int i;

        for (i=0; i<256; i++)
        {
                char c=(char)i;
                unsigned char uc=(unsigned char)i;

                if ( (((c >> 7) & 1) != ((uc >> 7) & 1)) ||
                     ((c & 15) != (uc & 15)))
                {
                        printf("Sam is wrong\n");
                        exit(0);
                }
        }
        printf("Sam is right\n");
        exit(0);
}


Please run this code, and let us know what happens.


Attachment: pgpVaxLr1PrHi.pgp
Description: PGP signature

Reply via email to