diff options
author | bms <bms@FreeBSD.org> | 2004-03-31 09:17:26 +0000 |
---|---|---|
committer | bms <bms@FreeBSD.org> | 2004-03-31 09:17:26 +0000 |
commit | 68fb152d91dbfeda2f1ab052c6c78cdc5d236344 (patch) | |
tree | 4be69f3369458972eebdcf559e348ee0518cec4f /contrib/tcpdump/smbutil.c | |
parent | 723e16349061e4b947ce1e5be04cdf68e1441b71 (diff) | |
parent | 281e9d71408deb6e8c5046c746c2e97002b0e7fe (diff) | |
download | FreeBSD-src-68fb152d91dbfeda2f1ab052c6c78cdc5d236344.zip FreeBSD-src-68fb152d91dbfeda2f1ab052c6c78cdc5d236344.tar.gz |
This commit was generated by cvs2svn to compensate for changes in r127668,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/tcpdump/smbutil.c')
-rw-r--r-- | contrib/tcpdump/smbutil.c | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/contrib/tcpdump/smbutil.c b/contrib/tcpdump/smbutil.c index 84c6f33..5c1350f 100644 --- a/contrib/tcpdump/smbutil.c +++ b/contrib/tcpdump/smbutil.c @@ -11,24 +11,15 @@ #endif #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.18.2.3 2002/07/10 07:29:23 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.26.2.2 2003/11/16 08:51:56 guy Exp $"; #endif -#include <sys/param.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> +#include <tcpdump-stdinc.h> -#include <netinet/in.h> - -#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#ifdef TIME_WITH_SYS_TIME -#include <time.h> -#endif #include "interface.h" #include "extract.h" @@ -261,10 +252,10 @@ print_asc(const unsigned char *buf, int len) safeputchar(buf[i]); } -static char * +static const char * name_type_str(int name_type) { - char *f = NULL; + const char *f = NULL; switch (name_type) { case 0: f = "Workstation"; break; @@ -322,9 +313,9 @@ print_data(const unsigned char *buf, int len) static void -write_bits(unsigned int val, char *fmt) +write_bits(unsigned int val, const char *fmt) { - char *p = fmt; + const char *p = fmt; int i = 0; while ((p = strchr(fmt, '|'))) { @@ -365,7 +356,7 @@ unistr(const u_char *s, int *len) *len = 1; } - while (l < (sizeof(buf) - 1) && s[0] && s[1] == 0) { + while (l < (int)(sizeof(buf) - 1) && s[0] && s[1] == 0) { buf[l] = s[0]; s += 2; l++; @@ -380,7 +371,7 @@ static const u_char * smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf) { int reverse = 0; - char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|"; + const char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|"; int len; while (*fmt && buf<maxbuf) { @@ -405,8 +396,12 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf) p = strchr(++fmt, '}'); l = PTR_DIFF(p, fmt); + + if ((unsigned int)l > sizeof(bitfmt) - 1) + l = sizeof(bitfmt)-1; + strncpy(bitfmt, fmt, l); - bitfmt[l] = 0; + bitfmt[l] = '\0'; fmt = p + 1; write_bits(buf[0], bitfmt); buf++; @@ -581,19 +576,21 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf) case 'T': { time_t t; - int x; + struct tm *lt; + const char *tstring; + u_int32_t x; x = EXTRACT_LE_32BITS(buf); switch (atoi(fmt + 1)) { case 1: - if (x == 0 || x == -1 || x == 0xFFFFFFFF) + if (x == 0 || x == 0xFFFFFFFF) t = 0; else t = make_unix_date(buf); buf += 4; break; case 2: - if (x == 0 || x == -1 || x == 0xFFFFFFFF) + if (x == 0 || x == 0xFFFFFFFF) t = 0; else t = make_unix_date2(buf); @@ -604,7 +601,15 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf) buf += 8; break; } - printf("%s", t ? asctime(localtime(&t)) : "NULL\n"); + if (t != 0) { + lt = localtime(&t); + if (lt != NULL) + tstring = asctime(lt); + else + tstring = "(Can't convert time)\n"; + } else + tstring = "NULL\n"; + printf("%s", tstring); fmt++; while (isdigit((unsigned char)*fmt)) fmt++; @@ -674,7 +679,7 @@ smb_fdata(const u_char *buf, const char *fmt, const u_char *maxbuf) return(buf); memset(s, 0, sizeof(s)); p = strchr(fmt, ']'); - if (p - fmt + 1 > sizeof(s)) { + if ((size_t)(p - fmt + 1) > sizeof(s)) { /* overrun */ return(buf); } @@ -801,7 +806,7 @@ err_code_struct hard_msgs[] = { static struct { int code; - char *class; + const char *class; err_code_struct *err_msgs; } err_classes[] = { { 0, "SUCCESS", NULL }, |