X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/922c8688c12fa46fe7d7061f3be813efa25d9d17..c0de704a5331dd3b9bd060dd0969163025186c0e:/print-smb.c diff --git a/print-smb.c b/print-smb.c index 95bd8d3b..b0940dfe 100644 --- a/print-smb.c +++ b/print-smb.c @@ -12,7 +12,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.36 2004-12-28 20:38:27 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.43 2005-05-08 19:59:57 guy Exp $"; #endif #include @@ -25,6 +25,7 @@ static const char rcsid[] _U_ = #include "smb.h" static int request = 0; +static int unicodestr = 0; const u_char *startbuf = NULL; @@ -94,11 +95,11 @@ trans2_findfirst(const u_char *param, const u_char *data, int pcnt, int dcnt) const char *fmt; if (request) - fmt = "Attribute=[A]\nSearchCount=[d]\nFlags=[w]\nLevel=[dP5]\nFile=[S]\n"; + fmt = "Attribute=[A]\nSearchCount=[d]\nFlags=[w]\nLevel=[dP4]\nFile=[S]\n"; else fmt = "Handle=[w]\nCount=[d]\nEOS=[w]\nEoffset=[d]\nLastNameOfs=[w]\n"; - smb_fdata(param, fmt, param + pcnt); + smb_fdata(param, fmt, param + pcnt, unicodestr); if (dcnt) { printf("data:\n"); print_data(data, dcnt); @@ -115,23 +116,23 @@ trans2_qfsinfo(const u_char *param, const u_char *data, int pcnt, int dcnt) TCHECK2(*param, 2); level = EXTRACT_LE_16BITS(param); fmt = "InfoLevel=[d]\n"; - smb_fdata(param, fmt, param + pcnt); + smb_fdata(param, fmt, param + pcnt, unicodestr); } else { switch (level) { case 1: 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"; break; } - smb_fdata(data, fmt, data + dcnt); + smb_fdata(data, fmt, data + dcnt, unicodestr); } if (dcnt) { printf("data:\n"); @@ -169,8 +170,9 @@ struct smbfnsint trans2_fns[] = { static void -print_trans2(const u_char *words, const u_char *dat _U_, const u_char *buf, const u_char *maxbuf) +print_trans2(const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf) { + u_int bcc; static struct smbfnsint *fn = &trans2_fns[0]; const u_char *data, *param; const u_char *w = words + 1; @@ -204,29 +206,31 @@ print_trans2(const u_char *words, const u_char *dat _U_, const u_char *buf, cons if (words[0] == 8) { smb_fdata(words + 1, "Trans2Secondary\nTotParam=[d]\nTotData=[d]\nParamCnt=[d]\nParamOff=[d]\nParamDisp=[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nHandle=[d]\n", - maxbuf); + maxbuf, unicodestr); 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", - words + 1 + 14 * 2); - smb_fdata(data + 1, "TransactionName=[S]\n%", maxbuf); + "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", - words + 1 + 10 * 2); + "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; } + TCHECK2(*dat, 2); + bcc = EXTRACT_LE_16BITS(dat); + printf("smb_bcc=%u\n", bcc); if (fn->descript.fn) (*fn->descript.fn)(param, data, pcnt, dcnt); else { - smb_fdata(param, f1 ? f1 : "Parameters=\n", param + pcnt); - smb_fdata(data, f2 ? f2 : "Data=\n", data + dcnt); + smb_fdata(param, f1 ? f1 : "Parameters=\n", param + pcnt, unicodestr); + smb_fdata(data, f2 ? f2 : "Data=\n", data + dcnt, unicodestr); } return; trunc: @@ -244,70 +248,70 @@ print_browse(const u_char *param, int paramlen, const u_char *data, int datalen) TCHECK(data[0]); command = data[0]; - smb_fdata(param, "BROWSE PACKET\n|Param ", param+paramlen); + smb_fdata(param, "BROWSE PACKET\n|Param ", param+paramlen, unicodestr); switch (command) { case 0xF: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (LocalMasterAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n", - maxbuf); + maxbuf, unicodestr); break; case 0x1: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (HostAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n", - maxbuf); + maxbuf, unicodestr); break; case 0x2: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (AnnouncementRequest)\nFlags=[B]\nReplySystemName=[S]\n", - maxbuf); + maxbuf, unicodestr); break; case 0xc: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (WorkgroupAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nCommentPointer=[W]\nServerName=[S]\n", - maxbuf); + maxbuf, unicodestr); break; case 0x8: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (ElectionFrame)\nElectionVersion=[B]\nOSSummary=[W]\nUptime=[(W, W)]\nServerName=[S]\n", - maxbuf); + maxbuf, unicodestr); break; case 0xb: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (BecomeBackupBrowser)\nName=[S]\n", - maxbuf); + maxbuf, unicodestr); break; case 0x9: data = smb_fdata(data, - "BROWSE PACKET:\nType=[B] (GetBackupList)\nListCount?=[B]\nToken?=[B]\n", - maxbuf); + "BROWSE PACKET:\nType=[B] (GetBackupList)\nListCount?=[B]\nToken=[W]\n", + maxbuf, unicodestr); break; case 0xa: data = smb_fdata(data, - "BROWSE PACKET:\nType=[B] (BackupListResponse)\nServerCount?=[B]\nToken?=[B]*Name=[S]\n", - maxbuf); + "BROWSE PACKET:\nType=[B] (BackupListResponse)\nServerCount?=[B]\nToken=[W]\n*Name=[S]\n", + maxbuf, unicodestr); break; case 0xd: data = smb_fdata(data, "BROWSE PACKET:\nType=[B] (MasterAnnouncement)\nMasterName=[S]\n", - maxbuf); + maxbuf, unicodestr); break; case 0xe: data = smb_fdata(data, - "BROWSE PACKET:\nType=[B] (ResetBrowser)\nOptions=[B]\n", maxbuf); + "BROWSE PACKET:\nType=[B] (ResetBrowser)\nOptions=[B]\n", maxbuf, unicodestr); break; default: - data = smb_fdata(data, "Unknown Browser Frame ", maxbuf); + data = smb_fdata(data, "Unknown Browser Frame ", maxbuf, unicodestr); break; } return; @@ -321,9 +325,10 @@ static void print_ipc(const u_char *param, int paramlen, const u_char *data, int datalen) { if (paramlen) - smb_fdata(param, "Command=[w]\nStr1=[S]\nStr2=[S]\n", param + paramlen); + smb_fdata(param, "Command=[w]\nStr1=[S]\nStr2=[S]\n", param + paramlen, + unicodestr); if (datalen) - smb_fdata(data, "IPC ", data + datalen); + smb_fdata(data, "IPC ", data + datalen, unicodestr); } @@ -358,13 +363,14 @@ print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u f4 = "|Data "; } - smb_fdata(words + 1, f1, SMBMIN(words + 1 + 2 * words[0], maxbuf)); + smb_fdata(words + 1, f1, SMBMIN(words + 1 + 2 * words[0], maxbuf), + unicodestr); TCHECK2(*data1, 2); bcc = EXTRACT_LE_16BITS(data1); printf("smb_bcc=%u\n", bcc); if (bcc > 0) { - smb_fdata(data1 + 2, f2, maxbuf - (paramlen + datalen)); + smb_fdata(data1 + 2, f2, maxbuf - (paramlen + datalen), unicodestr); if (strcmp((const char *)(data1 + 2), "\\MAILSLOT\\BROWSE") == 0) { print_browse(param, paramlen, data, datalen); @@ -377,9 +383,9 @@ print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u } if (paramlen) - smb_fdata(param, f3, SMBMIN(param + paramlen, maxbuf)); + smb_fdata(param, f3, SMBMIN(param + paramlen, maxbuf), unicodestr); if (datalen) - smb_fdata(data, f4, SMBMIN(data + datalen, maxbuf)); + smb_fdata(data, f4, SMBMIN(data + datalen, maxbuf), unicodestr); } return; trunc: @@ -397,7 +403,7 @@ print_negprot(const u_char *words, const u_char *data, const u_char *buf _U_, co TCHECK(words[0]); wct = words[0]; if (request) - f2 = "*|Dialect=[Z]\n"; + f2 = "*|Dialect=[Y]\n"; else { if (wct == 1) f1 = "Core Protocol\nDialectIndex=[d]"; @@ -408,7 +414,8 @@ print_negprot(const u_char *words, const u_char *data, const u_char *buf _U_, co } if (f1) - smb_fdata(words + 1, f1, SMBMIN(words + 1 + wct * 2, maxbuf)); + smb_fdata(words + 1, f1, SMBMIN(words + 1 + wct * 2, maxbuf), + unicodestr); else print_data(words + 1, SMBMIN(wct * 2, PTR_DIFF(maxbuf, words + 1))); @@ -417,7 +424,8 @@ print_negprot(const u_char *words, const u_char *data, const u_char *buf _U_, co printf("smb_bcc=%u\n", bcc); if (bcc > 0) { if (f2) - smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data), maxbuf)); + smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data), + maxbuf), unicodestr); else print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2))); } @@ -450,7 +458,8 @@ print_sesssetup(const u_char *words, const u_char *data, const u_char *buf _U_, } if (f1) - smb_fdata(words + 1, f1, SMBMIN(words + 1 + wct * 2, maxbuf)); + smb_fdata(words + 1, f1, SMBMIN(words + 1 + wct * 2, maxbuf), + unicodestr); else print_data(words + 1, SMBMIN(wct * 2, PTR_DIFF(maxbuf, words + 1))); @@ -459,7 +468,8 @@ print_sesssetup(const u_char *words, const u_char *data, const u_char *buf _U_, printf("smb_bcc=%u\n", bcc); if (bcc > 0) { if (f2) - smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data), maxbuf)); + smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data), + maxbuf), unicodestr); else print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2))); } @@ -491,14 +501,15 @@ print_lockingandx(const u_char *words, const u_char *data, const u_char *buf _U_ maxwords = SMBMIN(words + 1 + wct * 2, maxbuf); if (wct) - smb_fdata(words + 1, f1, maxwords); + smb_fdata(words + 1, f1, maxwords, unicodestr); TCHECK2(*data, 2); bcc = EXTRACT_LE_16BITS(data); printf("smb_bcc=%u\n", bcc); if (bcc > 0) { if (f2) - smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data), maxbuf)); + smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data), + maxbuf), unicodestr); else print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2))); } @@ -750,7 +761,7 @@ static struct smbfns smb_fns[] = { { SMBtconX, "SMBtconX", FLG_CHAIN, { "Com2=[w]\nOff2=[d]\nFlags=[w]\nPassLen=[d]\nPasswd&Path&Device=\n", - NULL, "Com2=[w]\nOff2=[d]\n", "ServiceType=[S]\n", NULL } }, + NULL, "Com2=[w]\nOff2=[d]\n", "ServiceType=[R]\n", NULL } }, { SMBlockingX, "SMBlockingX", FLG_CHAIN, { NULL, NULL, NULL, NULL, print_lockingandx } }, @@ -766,8 +777,8 @@ static struct smbfns smb_fns[] = { { 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 } }, @@ -783,7 +794,10 @@ static struct smbfns smb_fns[] = { static void print_smb(const u_char *buf, const u_char *maxbuf) { + u_int16_t flags2; + int nterrcodes; int command; + u_int32_t nterror; const u_char *words, *maxwords, *data; struct smbfns *fn; const char *fmt_smbheader = @@ -792,6 +806,10 @@ print_smb(const u_char *buf, const u_char *maxbuf) TCHECK(buf[9]); request = (buf[9] & 0x80) ? 0 : 1; + flags2 = EXTRACT_LE_16BITS(&buf[10]); + unicodestr = flags2 & 0x8000; + nterrcodes = flags2 & 0x4000; + startbuf = buf; command = buf[4]; @@ -806,10 +824,16 @@ print_smb(const u_char *buf, const u_char *maxbuf) return; /* print out the header */ - smb_fdata(buf, fmt_smbheader, buf + 33); + smb_fdata(buf, fmt_smbheader, buf + 33, unicodestr); - if (buf[5]) - printf("SMBError = %s\n", smb_errstr(buf[5], EXTRACT_LE_16BITS(&buf[7]))); + if (nterrcodes) { + nterror = EXTRACT_LE_32BITS(&buf[5]); + if (nterror) + printf("NTError = %s\n", nt_errstr(nterror)); + } else { + if (buf[5]) + printf("SMBError = %s\n", smb_errstr(buf[5], EXTRACT_LE_16BITS(&buf[7]))); + } smboffset = 32; @@ -838,7 +862,7 @@ print_smb(const u_char *buf, const u_char *maxbuf) else { if (wct) { if (f1) - smb_fdata(words + 1, f1, maxwords); + smb_fdata(words + 1, f1, words + 1 + wct * 2, unicodestr); else { int i; int v; @@ -856,7 +880,7 @@ print_smb(const u_char *buf, const u_char *maxbuf) printf("smb_bcc=%u\n", bcc); if (f2) { if (bcc > 0) - smb_fdata(data + 2, f2, data + 2 + bcc); + smb_fdata(data + 2, f2, data + 2 + bcc, unicodestr); } else { if (bcc > 0) { printf("smb_buf[]=\n"); @@ -901,17 +925,25 @@ trunc: void nbt_tcp_print(const u_char *data, int length) { - const u_char *maxbuf = data + length; + int caplen; int type; u_int nbt_len; + const u_char *maxbuf; - TCHECK2(data[2], 2); + if (length < 4) + goto trunc; + if (snapend < data) + goto trunc; + caplen = snapend - data; + if (caplen < 4) + goto trunc; + maxbuf = data + caplen; type = data[0]; nbt_len = EXTRACT_16BITS(data + 2); + length -= 4; + caplen -= 4; startbuf = data; - if (maxbuf <= data) - return; if (vflag < 2) { printf(" NBT Session Packet: "); @@ -932,7 +964,12 @@ nbt_tcp_print(const u_char *data, int length) { int ecode; - TCHECK(data[4]); + if (nbt_len < 4) + goto trunc; + if (length < 4) + goto trunc; + if (caplen < 4) + goto trunc; ecode = data[4]; printf("Session Reject, "); @@ -961,7 +998,7 @@ nbt_tcp_print(const u_char *data, int length) break; default: - data = smb_fdata(data, "Unknown packet type [rB]", maxbuf); + data = smb_fdata(data, "Unknown packet type [rB]", maxbuf, 0); break; } } else { @@ -969,63 +1006,71 @@ nbt_tcp_print(const u_char *data, int length) switch (type) { case 0x00: data = smb_fdata(data, "[P1]NBT Session Message\nFlags=[B]\nLength=[rd]\n", - data + 4); + data + 4, 0); if (data == NULL) break; - if (memcmp(data,"\377SMB",4) == 0) { - if (nbt_len > PTR_DIFF(maxbuf, data)) - printf("WARNING: Short packet. Try increasing the snap length (%lu)\n", - (unsigned long)PTR_DIFF(maxbuf, data)); + if (nbt_len >= 4 && caplen >= 4 && memcmp(data,"\377SMB",4) == 0) { + if ((int)nbt_len > caplen) { + if ((int)nbt_len > length) + printf("WARNING: Packet is continued in later TCP segments\n"); + else + printf("WARNING: Short packet. Try increasing the snap length by %d\n", + nbt_len - caplen); + } print_smb(data, maxbuf > data + nbt_len ? data + nbt_len : maxbuf); } else - printf("Session packet:(raw data?)\n"); + printf("Session packet:(raw data or continuation?)\n"); break; case 0x81: data = smb_fdata(data, "[P1]NBT Session Request\nFlags=[B]\nLength=[rd]\nDestination=[n1]\nSource=[n1]\n", - maxbuf); + maxbuf, 0); break; case 0x82: - data = smb_fdata(data, "[P1]NBT Session Granted\nFlags=[B]\nLength=[rd]\n", maxbuf); + data = smb_fdata(data, "[P1]NBT Session Granted\nFlags=[B]\nLength=[rd]\n", maxbuf, 0); break; case 0x83: { + const u_char *origdata; int ecode; - TCHECK(data[4]); - ecode = data[4]; - + origdata = data; data = smb_fdata(data, "[P1]NBT SessionReject\nFlags=[B]\nLength=[rd]\nReason=[B]\n", - maxbuf); - switch (ecode) { - case 0x80: - printf("Not listening on called name\n"); - break; - case 0x81: - printf("Not listening for calling name\n"); - break; - case 0x82: - printf("Called name not present\n"); - break; - case 0x83: - printf("Called name present, but insufficient resources\n"); - break; - default: - printf("Unspecified error 0x%X\n", ecode); + maxbuf, 0); + if (data == NULL) break; + if (nbt_len >= 1 && caplen >= 1) { + ecode = origdata[4]; + switch (ecode) { + case 0x80: + printf("Not listening on called name\n"); + break; + case 0x81: + printf("Not listening for calling name\n"); + break; + case 0x82: + printf("Called name not present\n"); + break; + case 0x83: + printf("Called name present, but insufficient resources\n"); + break; + default: + printf("Unspecified error 0x%X\n", ecode); + break; + } } } break; case 0x85: - data = smb_fdata(data, "[P1]NBT Session Keepalive\nFlags=[B]\nLength=[rd]\n", maxbuf); + data = smb_fdata(data, "[P1]NBT Session Keepalive\nFlags=[B]\nLength=[rd]\n", maxbuf, 0); break; default: - data = smb_fdata(data, "NBT - Unknown packet type\nType=[B]\n", maxbuf); + data = smb_fdata(data, "NBT - Unknown packet type\nType=[B]\n", maxbuf, 0); break; } printf("\n"); @@ -1117,12 +1162,13 @@ nbt_udp137_print(const u_char *data, int length) if (qdcount) { printf("QuestionRecords:\n"); - for (i = 0; i < qdcount; i++) + for (i = 0; i < qdcount; i++) { p = smb_fdata(p, "|Name=[n1]\nQuestionType=[rw]\nQuestionClass=[rw]\n#", - maxbuf); - if (p == NULL) - goto out; + maxbuf, 0); + if (p == NULL) + goto out; + } } if (total) { @@ -1131,18 +1177,18 @@ nbt_udp137_print(const u_char *data, int length) int rdlen; int restype; - p = smb_fdata(p, "Name=[n1]\n#", maxbuf); + p = smb_fdata(p, "Name=[n1]\n#", maxbuf, 0); if (p == NULL) goto out; restype = EXTRACT_16BITS(p); - p = smb_fdata(p, "ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n", p + 8); + p = smb_fdata(p, "ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n", p + 8, 0); if (p == NULL) goto out; rdlen = EXTRACT_16BITS(p); printf("ResourceLength=%d\nResourceData=\n", rdlen); p += 2; if (rdlen == 6) { - p = smb_fdata(p, "AddrType=[rw]\nAddress=[b.b.b.b]\n", p + rdlen); + p = smb_fdata(p, "AddrType=[rw]\nAddress=[b.b.b.b]\n", p + rdlen, 0); if (p == NULL) goto out; } else { @@ -1151,11 +1197,13 @@ nbt_udp137_print(const u_char *data, int length) TCHECK(*p); numnames = p[0]; - p = smb_fdata(p, "NumNames=[B]\n", p + 1); + p = smb_fdata(p, "NumNames=[B]\n", p + 1, 0); if (p == NULL) goto out; while (numnames--) { - p = smb_fdata(p, "Name=[n2]\t#", maxbuf); + p = smb_fdata(p, "Name=[n2]\t#", maxbuf, 0); + if (p == NULL) + goto out; TCHECK(*p); if (p[0] & 0x80) printf(" "); @@ -1185,7 +1233,7 @@ nbt_udp137_print(const u_char *data, int length) } if (p < maxbuf) - smb_fdata(p, "AdditionalData:\n", maxbuf); + smb_fdata(p, "AdditionalData:\n", maxbuf, 0); out: printf("\n"); @@ -1219,7 +1267,7 @@ nbt_udp138_print(const u_char *data, int length) data = smb_fdata(data, "\n>>> NBT UDP PACKET(138) Res=[rw] ID=[rw] IP=[b.b.b.b] Port=[rd] Length=[rd] Res2=[rw]\nSourceName=[n1]\nDestName=[n1]\n#", - maxbuf); + maxbuf, 0); if (data != NULL) { /* If there isn't enough data for "\377SMB", don't check for it. */ @@ -1317,28 +1365,28 @@ netbeui_print(u_short control, const u_char *data, int length) if (vflag < 2) { printf("NBF Packet: "); - data = smb_fdata(data, "[P5]#", maxbuf); + data = smb_fdata(data, "[P5]#", maxbuf, 0); } else { printf("\n>>> NBF Packet\nType=0x%X ", control); - data = smb_fdata(data, "Length=[d] Signature=[w] Command=[B]\n#", maxbuf); + data = smb_fdata(data, "Length=[d] Signature=[w] Command=[B]\n#", maxbuf, 0); } if (data == NULL) goto out; if (command > 0x1f || nbf_strings[command].name == NULL) { if (vflag < 2) - data = smb_fdata(data, "Unknown NBF Command#", data2); + data = smb_fdata(data, "Unknown NBF Command#", data2, 0); else - data = smb_fdata(data, "Unknown NBF Command\n", data2); + data = smb_fdata(data, "Unknown NBF Command\n", data2, 0); } else { if (vflag < 2) { printf("%s", nbf_strings[command].name); if (nbf_strings[command].nonverbose != NULL) - data = smb_fdata(data, nbf_strings[command].nonverbose, data2); + data = smb_fdata(data, nbf_strings[command].nonverbose, data2, 0); } else { printf("%s:\n", nbf_strings[command].name); if (nbf_strings[command].verbose != NULL) - data = smb_fdata(data, nbf_strings[command].verbose, data2); + data = smb_fdata(data, nbf_strings[command].verbose, data2, 0); else printf("\n"); } @@ -1410,7 +1458,7 @@ ipx_netbios_print(const u_char *data, u_int length) if (&data[i + 4] > maxbuf) break; if (memcmp(&data[i], "\377SMB", 4) == 0) { - smb_fdata(data, "\n>>> IPX transport ", &data[i]); + smb_fdata(data, "\n>>> IPX transport ", &data[i], 0); if (data != NULL) print_smb(&data[i], maxbuf); printf("\n"); @@ -1419,5 +1467,5 @@ ipx_netbios_print(const u_char *data, u_int length) } } if (i == 128) - smb_fdata(data, "\n>>> Unknown IPX ", maxbuf); + smb_fdata(data, "\n>>> Unknown IPX ", maxbuf, 0); }