#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.39 2004-12-29 02:43:24 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.40 2004-12-29 03:10:24 guy Exp $";
#endif
#include <tcpdump-stdinc.h>
fmt = "idFileSystem=[W]\nSectorUnit=[D]\nUnit=[D]\nAvail=[D]\nSectorSize=[d]\n";
break;
case 2:
- fmt = "CreationTime=[T2]VolNameLength=[B]\nVolumeLabel=[s12]\n";
+ fmt = "CreationTime=[T2]VolNameLength=[lb]\nVolumeLabel=[c]\n";
break;
case 0x105:
- fmt = "Capabilities=[W]\nMaxFileLen=[D]\nVolNameLen=[D]\nVolume=[S]\n";
+ fmt = "Capabilities=[W]\nMaxFileLen=[D]\nVolNameLen=[lD]\nVolume=[C]\n";
break;
default:
fmt = "UnknownLevel\n";
return;
} else {
smb_fdata(words + 1,
- "TotParam=[d]\nTotData=[d]\nMaxParam=[d]\nMaxData=[d]\nMaxSetup=[d]\nFlags=[w]\nTimeOut=[D]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nDataCnt=[d]\nDataOff=[d]\nSetupCnt=[d]\n",
+ "TotParam=[d]\nTotData=[d]\nMaxParam=[d]\nMaxData=[d]\nMaxSetup=[b][P1]\nFlags=[w]\nTimeOut=[D]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nDataCnt=[d]\nDataOff=[d]\nSetupCnt=[b][P1]\n",
words + 1 + 14 * 2, unicodestr);
}
f1 = fn->descript.req_f1;
f2 = fn->descript.req_f2;
} else {
smb_fdata(words + 1,
- "TotParam=[d]\nTotData=[d]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nParamDisp[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nSetupCnt=[d]\n",
+ "TotParam=[d]\nTotData=[d]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nParamDisp[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nSetupCnt=[b][P1]\n",
words + 1 + 10 * 2, unicodestr);
f1 = fn->descript.rep_f1;
f2 = fn->descript.rep_f2;
{ SMBnttranss, "SMBnttranss", 0, DEFDESCRIPT },
{ SMBntcreateX, "SMBntcreateX", FLG_CHAIN,
- { "Com2=[w]\nOff2=[d]\nRes=[b]\nNameLen=[d]\nFlags=[W]\nRootDirectoryFid=[D]\nAccessMask=[W]\nAllocationSize=[L]\nExtFileAttributes=[W]\nShareAccess=[W]\nCreateDisposition=[W]\nCreateOptions=[W]\nImpersonationLevel=[W]\nSecurityFlags=[b]\n",
- "Path=[S]\n",
+ { "Com2=[w]\nOff2=[d]\nRes=[b]\nNameLen=[ld]\nFlags=[W]\nRootDirectoryFid=[D]\nAccessMask=[W]\nAllocationSize=[L]\nExtFileAttributes=[W]\nShareAccess=[W]\nCreateDisposition=[W]\nCreateOptions=[W]\nImpersonationLevel=[W]\nSecurityFlags=[b]\n",
+ "Path=[C]\n",
"Com2=[w]\nOff2=[d]\nOplockLevel=[b]\nFid=[d]\nCreateAction=[W]\nCreateTime=[T3]LastAccessTime=[T3]LastWriteTime=[T3]ChangeTime=[T3]ExtFileAttributes=[W]\nAllocationSize=[L]\nEndOfFile=[L]\nFileType=[w]\nDeviceState=[w]\nDirectory=[b]\n",
NULL, NULL } },
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.32 2004-12-28 22:29:45 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.33 2004-12-29 03:10:25 guy Exp $";
#endif
#include <tcpdump-stdinc.h>
#include "extract.h"
#include "smb.h"
+static u_int32_t stringlen;
extern const u_char *startbuf;
/*
}
/* convert a UCS2 string into iso-8859-1 string */
+#define MAX_UNISTR_SIZE 1000
static const char *
-unistr(const u_char *s, int *len, int use_unicode)
+unistr(const u_char *s, u_int32_t *len, int use_unicode)
{
- static char buf[1000];
- int l=0;
-
- if (!use_unicode) {
- *len = strlen((const char *)s) + 1;
- return (const char *)s;
+ static char buf[MAX_UNISTR_SIZE+1];
+ size_t l = 0;
+ u_int32_t strsize;
+ const u_char *sp;
+
+ if (use_unicode) {
+ /*
+ * Skip padding that puts the string on an even boundary.
+ */
+ if (((s - startbuf) % 2) != 0)
+ s++;
}
-
- /*
- * Skip padding that puts the string on an even boundary.
- */
- if (((s - startbuf) % 2) != 0)
- s++;
-
- *len = 0;
-
- if (s[0] == 0 && s[1] != 0) {
- s++;
- *len = 1;
+ if (*len == 0) {
+ /*
+ * Null-terminated string.
+ */
+ strsize = 0;
+ sp = s;
+ if (!use_unicode) {
+ for (;;) {
+ *len += 1;
+ if (sp[0] == 0)
+ break;
+ sp++;
+ }
+ strsize = *len - 1;
+ } else {
+ for (;;) {
+ *len += 2;
+ if (sp[0] == 0 && sp[1] == 0)
+ break;
+ sp += 2;
+ }
+ strsize = *len - 2;
+ }
+ } else {
+ /*
+ * Counted string.
+ */
+ strsize = *len;
}
-
- while (l < (int)(sizeof(buf) - 1) && s[0] && s[1] == 0) {
- buf[l] = s[0];
- s += 2;
- l++;
- *len += 2;
+ if (!use_unicode) {
+ while (strsize != 0) {
+ if (l >= MAX_UNISTR_SIZE)
+ break;
+ if (isprint(s[0]))
+ buf[l] = s[0];
+ else {
+ if (s[0] == 0)
+ break;
+ buf[l] = '.';
+ }
+ l++;
+ s++;
+ strsize--;
+ }
+ } else {
+ while (strsize != 0) {
+ if (l >= MAX_UNISTR_SIZE)
+ break;
+ if (s[1] == 0 && isprint(s[0])) {
+ /* It's a printable ASCII character */
+ buf[l] = s[0];
+ } else {
+ /* It's a non-ASCII character or a non-printable ASCII character */
+ if (s[0] == 0 && s[1] == 0)
+ break;
+ buf[l] = '.';
+ }
+ l++;
+ s += 2;
+ if (strsize == 1)
+ break;
+ strsize -= 2;
+ }
}
buf[l] = 0;
- *len += 2;
return buf;
}
fmt++;
break;
}
+ case 'l':
+ {
+ fmt++;
+ switch (*fmt) {
+
+ case 'b':
+ TCHECK(buf[0]);
+ stringlen = buf[0];
+ printf("%u", stringlen);
+ buf += 1;
+ break;
+
+ case 'd':
+ TCHECK2(buf[0], 2);
+ stringlen = reverse ? EXTRACT_16BITS(buf) :
+ EXTRACT_LE_16BITS(buf);
+ printf("%u", stringlen);
+ buf += 2;
+ break;
+
+ case 'D':
+ TCHECK2(buf[0], 4);
+ stringlen = reverse ? EXTRACT_32BITS(buf) :
+ EXTRACT_LE_32BITS(buf);
+ printf("%u", stringlen);
+ buf += 4;
+ break;
+ }
+ fmt++;
+ break;
+ }
case 'S':
case 'R': /* like 'S', but always ASCII */
{
/*XXX unistr() */
- printf("%.*s", (int)PTR_DIFF(maxbuf, buf),
- unistr(buf, &len, (*fmt == 'R') ? 0 : unicodestr));
+ len = 0;
+ printf("%s", unistr(buf, &len, (*fmt == 'R') ? 0 : unicodestr));
buf += len;
fmt++;
break;
if (*buf != 4 && *buf != 2)
printf("Error! ASCIIZ buffer of type %u (safety=%lu)\n", *buf,
(unsigned long)PTR_DIFF(maxbuf, buf));
- printf("%.*s", (int)PTR_DIFF(maxbuf, buf + 1),
- unistr(buf + 1, &len, (*fmt == 'Y') ? 0 : unicodestr));
+ len = 0;
+ printf("%s", unistr(buf + 1, &len, (*fmt == 'Y') ? 0 : unicodestr));
buf += len + 1;
fmt++;
break;
fmt++;
break;
}
+ case 'c':
+ {
+ TCHECK2(*buf, stringlen);
+ printf("%-*.*s", stringlen, stringlen, buf);
+ buf += stringlen;
+ fmt++;
+ while (isdigit((unsigned char)*fmt))
+ fmt++;
+ break;
+ }
+ case 'C':
+ {
+ const char *s;
+ s = unistr(buf, &stringlen, unicodestr);
+ if (s == NULL)
+ goto trunc;
+ printf("%s", s);
+ buf += stringlen;
+ fmt++;
+ break;
+ }
case 'h':
{
int l = atoi(fmt + 1);