* Routines for smb packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
- * $Id: packet-smb.c,v 1.71 2000/08/13 14:08:50 deniel Exp $
+ * $Id: packet-smb.c,v 1.76 2000/12/17 03:48:44 sharpe Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
#include "conversation.h"
#include "smb.h"
#include "alignment.h"
+#include "strutil.h"
guint32 dissect_mailslot_smb(const u_char *, int, frame_data *, proto_tree *, proto_tree *, struct smb_info, int, int, int, int, const u_char *, int, int, int, int);
dissect_smbu_date(guint16 date, guint16 time)
{
- static char datebuf[4+2+2+2+1];
+ static char datebuf[4+2+2+2+1+10];
time_t ltime = (date << 16) + time;
_gtime = gmtime(<ime);
- sprintf(datebuf, "%04d-%02d-%02d",
- 1900 + (_gtime -> tm_year), 1 + (_gtime -> tm_mon), _gtime -> tm_mday);
+
+ if (_gtime)
+ sprintf(datebuf, "%04d-%02d-%02d",
+ 1900 + (_gtime -> tm_year), 1 + (_gtime -> tm_mon), _gtime -> tm_mday);
+ else
+ sprintf(datebuf, "Bad date format");
return datebuf;
dissect_smbu_time(guint16 date, guint16 time)
{
- static char timebuf[2+2+2+2+1];
+ static char timebuf[2+2+2+2+1+10];
- sprintf(timebuf, "%02d:%02d:%02d",
- _gtime -> tm_hour, _gtime -> tm_min, _gtime -> tm_sec);
+ if (_gtime)
+ sprintf(timebuf, "%02d:%02d:%02d",
+ _gtime -> tm_hour, _gtime -> tm_min, _gtime -> tm_sec);
+ else
+ sprintf(timebuf, "Bad time format");
return timebuf;
proto_tree_add_text(tree, NullTVB, offset, 2, "Last Write Date: %s", dissect_smbu_date(LastWriteDate, LastWriteTime));
- proto_tree_add_text(tree, NullTVB, offset, 2, "Last Write Time: %s", dissect_smbu_time(LastWriteDate, LastWriteTime));
+ proto_tree_add_text(tree, NullTVB, offset - 2, 2, "Last Write Time: %s", dissect_smbu_time(LastWriteDate, LastWriteTime));
}
* packets from B:Y to A:X.
*/
conversation = find_conversation(&pi.src, &pi.dst, pi.ptype,
- pi.srcport, pi.destport);
+ pi.srcport, pi.destport, 0);
if (conversation == NULL) {
/* It's not part of any conversation - create a new one. */
conversation = conversation_new(&pi.src, &pi.dst, pi.ptype,
- pi.srcport, pi.destport, NULL);
+ pi.srcport, pi.destport, NULL, 0);
}
si.conversation = conversation; /* Save this for later */
if (!TransactName)
return;
- TransactNameCopy = g_malloc(strlen(TransactName) + 1);
+ TransactNameCopy = g_malloc(TransactName ? strlen(TransactName) + 1 : 1);
/* Should check for error here ... */
- strcpy(TransactNameCopy, TransactName);
+ strcpy(TransactNameCopy, TransactName ? TransactName : "");
if (TransactNameCopy[0] == '\\') {
trans_type = TransactNameCopy + 1; /* Skip the slash */
- loc_of_slash = strchr(trans_type, '\\');
+ loc_of_slash = trans_type ? strchr(trans_type, '\\') : NULL;
}
if (loc_of_slash) {
trans_cmd = NULL;
if ((trans_cmd == NULL) ||
- (((strcmp(trans_type, "MAILSLOT") != 0) ||
+ (((trans_type == NULL || strcmp(trans_type, "MAILSLOT") != 0) ||
!dissect_mailslot_smb(pd, SetupAreaOffset, fd, parent, tree, si, max_data, SMB_offset, errcode, dirn, trans_cmd, SMB_offset + DataOffset, DataCount, SMB_offset + ParameterOffset, ParameterCount)) &&
- ((strcmp(trans_type, "PIPE") != 0) ||
+ ((trans_type == NULL || strcmp(trans_type, "PIPE") != 0) ||
!dissect_pipe_smb(pd, offset, fd, parent, tree, si, max_data, SMB_offset, errcode, dirn, trans_cmd, DataOffset, DataCount, ParameterOffset, ParameterCount)))) {
if (ParameterCount > 0) {
*/
conversation = find_conversation(&pi.src, &pi.dst, pi.ptype,
- pi.srcport, pi.destport);
+ pi.srcport, pi.destport, 0);
if (conversation == NULL) { /* Create a new conversation */
conversation = conversation_new(&pi.src, &pi.dst, pi.ptype,
- pi.srcport, pi.destport, NULL);
+ pi.srcport, pi.destport, NULL, 0);
}
cmd = pd[offset + SMB_hdr_com_offset];
if (check_col(fd, COL_PROTOCOL))
- col_add_str(fd, COL_PROTOCOL, "SMB");
+ col_set_str(fd, COL_PROTOCOL, "SMB");
/* Hmmm, poor coding here ... Also, should check the type */