--- cvsnt-2.5.03.2382/protocols/ntlm/smbutil.c.orig 2006-10-21 03:30:43.000000000 +0200 +++ cvsnt-2.5.03.2382/protocols/ntlm/smbutil.c 2006-10-24 21:41:12.000000000 +0200 @@ -63,13 +63,26 @@ char versionString[] = PACKAGE_STRING; /* I am not crazy about these macros -- they seem to have gotten * a bit complex. A new scheme for handling string/buffer fields * in the structures probably needs to be designed + * + * The special handling for zero length items is necessary so the offset + * does not point past end of message if the last item of the message + * has zero length (otherwise server responds with "The parameter is + * incorrect."). However if the item length is zero it doesn't matter + * where exactly the offset points to, I think. We just set it to zero. */ #define AddBytes(ptr, header, buf, count) \ { \ ptr->header.len = ptr->header.maxlen = UI16LE(count); \ - ptr->header.offset = UI32LE((ptr->buffer - ((uint8*)ptr)) + ptr->bufIndex); \ - memcpy(ptr->buffer+ptr->bufIndex, buf, count); \ - ptr->bufIndex += count; \ + if (buf && count) \ + { \ + ptr->header.offset = UI32LE((ptr->buffer - ((uint8*)ptr)) + ptr->bufIndex); \ + memcpy(ptr->buffer+ptr->bufIndex, buf, count); \ + ptr->bufIndex += count; \ + } \ + else \ + { \ + ptr->header.offset = 0; \ + } \ } #define AddString(ptr, header, string) \