summaryrefslogtreecommitdiff
path: root/smbutil.c
diff options
context:
space:
mode:
authoritojun <itojun>2001-06-25 18:58:07 +0000
committeritojun <itojun>2001-06-25 18:58:07 +0000
commita1d73ea7ee29b89184a4e367b7169a18ff13d3e2 (patch)
tree4d9e878d14e1972458530e73814b6c64f566fbed /smbutil.c
parent4b158e394b5b80ee56c2046a67f76df699e691f9 (diff)
downloadtcpdump-a1d73ea7ee29b89184a4e367b7169a18ff13d3e2.tar.gz
more audit/style. fix a couple of signed/unsigned mixup,
printf type mismatch, as well as buffer overrun possibilities
Diffstat (limited to 'smbutil.c')
-rw-r--r--smbutil.c803
1 files changed, 413 insertions, 390 deletions
diff --git a/smbutil.c b/smbutil.c
index 58e18b5d..ab5afbf4 100644
--- a/smbutil.c
+++ b/smbutil.c
@@ -11,7 +11,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.14 2001-06-15 07:43:13 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.15 2001-06-25 18:58:09 itojun Exp $";
#endif
#include <sys/param.h>
@@ -336,422 +336,445 @@ static const char *unistr(const char *s, int *len)
return buf;
}
-static const uchar *fdata1(const uchar *buf, const char *fmt, const uchar *maxbuf)
+static const uchar *
+fdata1(const uchar *buf, const char *fmt, const uchar *maxbuf)
{
- int reverse=0;
- char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|";
- int len;
+ int reverse = 0;
+ char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|";
+ int len;
+
+ while (*fmt && buf<maxbuf) {
+ switch (*fmt) {
+ case 'a':
+ write_bits(CVAL(buf,0), attrib_fmt);
+ buf++;
+ fmt++;
+ break;
+
+ case 'A':
+ write_bits(SVAL(buf, 0), attrib_fmt);
+ buf += 2;
+ fmt++;
+ break;
+
+ case '{':
+ {
+ char bitfmt[128];
+ char *p = strchr(++fmt, '}');
+ int l = PTR_DIFF(p, fmt);
+ strncpy(bitfmt, fmt, l);
+ bitfmt[l] = 0;
+ fmt = p + 1;
+ write_bits(CVAL(buf, 0), bitfmt);
+ buf++;
+ break;
+ }
- while (*fmt && buf<maxbuf) {
- switch (*fmt) {
- case 'a':
- write_bits(CVAL(buf,0),attrib_fmt);
- buf++; fmt++;
- break;
-
- case 'A':
- write_bits(SVAL(buf,0),attrib_fmt);
- buf+=2; fmt++;
- break;
-
- case '{':
- {
- char bitfmt[128];
- char *p = strchr(++fmt,'}');
- int l = PTR_DIFF(p,fmt);
- strncpy(bitfmt,fmt,l);
- bitfmt[l]=0;
- fmt = p+1;
- write_bits(CVAL(buf,0),bitfmt);
- buf++;
- break;
- }
+ case 'P':
+ {
+ int l = atoi(fmt + 1);
+ buf += l;
+ fmt++;
+ while (isdigit(*fmt))
+ fmt++;
+ break;
+ }
+ case 'r':
+ reverse = !reverse;
+ fmt++;
+ break;
+ case 'D':
+ {
+ unsigned int x = reverse ? RIVAL(buf, 0) : IVAL(buf, 0);
+ printf("%d (0x%x)", x, x);
+ buf += 4;
+ fmt++;
+ break;
+ }
+ case 'L':
+ {
+ unsigned int x1 = reverse ? RIVAL(buf, 0) : IVAL(buf, 0);
+ unsigned int x2 = reverse ? RIVAL(buf, 4) : IVAL(buf, 4);
+ if (x2)
+ printf("0x%08x:%08x", x2, x1);
+ else
+ printf("%d (0x%08x%08x)", x1, x2, x1);
+ buf += 8;
+ fmt++;
+ break;
+ }
+ case 'd':
+ {
+ unsigned int x = reverse ? RSVAL(buf, 0) : SVAL(buf, 0);
+ printf("%d (0x%x)", x, x);
+ buf += 2;
+ fmt++;
+ break;
+ }
+ case 'W':
+ {
+ unsigned int x = reverse ? RIVAL(buf, 0) : IVAL(buf, 0);
+ printf("0x%X", x);
+ buf += 4;
+ fmt++;
+ break;
+ }
+ case 'w':
+ {
+ unsigned int x = reverse ? RSVAL(buf, 0) : SVAL(buf, 0);
+ printf("0x%X", x);
+ buf += 2;
+ fmt++;
+ break;
+ }
+ case 'B':
+ {
+ unsigned int x = CVAL(buf,0);
+ printf("0x%X", x);
+ buf += 1;
+ fmt++;
+ break;
+ }
+ case 'b':
+ {
+ unsigned int x = CVAL(buf, 0);
+ printf("%u (0x%x)", x, x);
+ buf += 1;
+ fmt++;
+ break;
+ }
+ case 'S':
+ {
+ printf("%.*s", (int)PTR_DIFF(maxbuf, buf), unistr(buf, &len));
+ buf += len;
+ fmt++;
+ break;
+ }
+ case 'Z':
+ {
+ 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));
+ buf += len + 1;
+ fmt++;
+ break;
+ }
+ case 's':
+ {
+ int l = atoi(fmt + 1);
+ printf("%-*.*s", l, l, buf);
+ buf += l;
+ fmt++;
+ while (isdigit(*fmt))
+ fmt++;
+ break;
+ }
+ case 'h':
+ {
+ int l = atoi(fmt + 1);
+ while (l--)
+ printf("%02x", *buf++);
+ fmt++;
+ while (isdigit(*fmt))
+ fmt++;
+ break;
+ }
+ case 'n':
+ {
+ int t = atoi(fmt+1);
+ char nbuf[255];
+ int name_type;
+ int len;
+
+ switch (t) {
+ case 1:
+ name_type = name_extract(startbuf, PTR_DIFF(buf, startbuf),
+ maxbuf, nbuf);
+ if (name_type < 0)
+ goto trunc;
+ len = name_len(buf, maxbuf);
+ if (len < 0)
+ goto trunc;
+ buf += len;
+ printf("%-15.15s NameType=0x%02X (%s)", nbuf, name_type,
+ name_type_str(name_type));
+ break;
+ case 2:
+ name_type = buf[15];
+ printf("%-15.15s NameType=0x%02X (%s)", buf, name_type,
+ name_type_str(name_type));
+ buf += 16;
+ break;
+ }
+ fmt++;
+ while (isdigit(*fmt))
+ fmt++;
+ break;
+ }
+ case 'T':
+ {
+ time_t t;
+ int x = IVAL(buf,0);
- case 'P':
- {
- int l = atoi(fmt+1);
- buf += l;
- fmt++;
- while (isdigit(*fmt)) fmt++;
- break;
- }
- case 'r':
- reverse = !reverse;
- fmt++;
- break;
- case 'D':
- {
- unsigned int x = reverse?RIVAL(buf,0):IVAL(buf,0);
- printf("%d (0x%x)",x, x);
- buf += 4;
- fmt++;
- break;
- }
- case 'L':
- {
- unsigned int x1 = reverse?RIVAL(buf,0):IVAL(buf,0);
- unsigned int x2 = reverse?RIVAL(buf,4):IVAL(buf,4);
- if (x2) {
- printf("0x%08x:%08x",x2, x1);
- } else {
- printf("%d (0x%08x%08x)",x1, x2, x1);
- }
- buf += 8;
- fmt++;
- break;
- }
- case 'd':
- {
- unsigned int x = reverse?RSVAL(buf,0):SVAL(buf,0);
- printf("%d (0x%x)",x, x);
- buf += 2;
- fmt++;
- break;
- }
- case 'W':
- {
- unsigned int x = reverse?RIVAL(buf,0):IVAL(buf,0);
- printf("0x%X",x);
- buf += 4;
- fmt++;
- break;
- }
- case 'w':
- {
- unsigned int x = reverse?RSVAL(buf,0):SVAL(buf,0);
- printf("0x%X",x);
- buf += 2;
- fmt++;
- break;
- }
- case 'B':
- {
- unsigned int x = CVAL(buf,0);
- printf("0x%X",x);
- buf += 1;
- fmt++;
- break;
- }
- case 'b':
- {
- unsigned int x = CVAL(buf,0);
- printf("%d (0x%x)",x, x);
- buf += 1;
- fmt++;
- break;
- }
- case 'S':
- {
- printf("%.*s",(int)PTR_DIFF(maxbuf,buf),unistr(buf, &len));
- buf += len;
- fmt++;
- break;
- }
- case 'Z':
- {
- if (*buf != 4 && *buf != 2)
- printf("Error! ASCIIZ buffer of type %d (safety=%d)\n",
- *buf,(int)PTR_DIFF(maxbuf,buf));
- printf("%.*s",(int)PTR_DIFF(maxbuf,buf+1),unistr(buf+1, &len));
- buf += len+1;
- fmt++;
- break;
- }
- case 's':
- {
- int l = atoi(fmt+1);
- printf("%-*.*s",l,l,buf);
- buf += l;
- fmt++; while (isdigit(*fmt)) fmt++;
- break;
- }
- case 'h':
- {
- int l = atoi(fmt+1);
- while (l--) printf("%02x",*buf++);
- fmt++; while (isdigit(*fmt)) fmt++;
- break;
- }
- case 'n':
- {
- int t = atoi(fmt+1);
- char nbuf[255];
- int name_type;
- int len;
- switch (t) {
- case 1:
- name_type = name_extract(startbuf,PTR_DIFF(buf,startbuf),maxbuf,
- nbuf);
- if (name_type < 0)
- goto trunc;
- len = name_len(buf,maxbuf);
- if (len < 0)
- goto trunc;
- buf += len;
- printf("%-15.15s NameType=0x%02X (%s)",
- nbuf,name_type,name_type_str(name_type));
- break;
- case 2:
- name_type = buf[15];
- printf("%-15.15s NameType=0x%02X (%s)",
- buf,name_type,name_type_str(name_type));
- buf += 16;
- break;
- }
- fmt++; while (isdigit(*fmt)) fmt++;
- break;
- }
- case 'T':
- {
- time_t t;
- int x = IVAL(buf,0);
- switch (atoi(fmt+1)) {
- case 1:
- if (x==0 || x==-1 || x==0xFFFFFFFF)
- t = 0;
- else
- t = make_unix_date(buf);
- buf+=4;
- break;
- case 2:
- if (x==0 || x==-1 || x==0xFFFFFFFF)
- t = 0;
- else
- t = make_unix_date2(buf);
- buf+=4;
- break;
- case 3:
- t = interpret_long_date(buf);
- buf+=8;
- break;
+ switch (atoi(fmt + 1)) {
+ case 1:
+ if (x == 0 || x == -1 || x == 0xFFFFFFFF)
+ t = 0;
+ else
+ t = make_unix_date(buf);
+ buf += 4;
+ break;
+ case 2:
+ if (x == 0 || x == -1 || x == 0xFFFFFFFF)
+ t = 0;
+ else
+ t = make_unix_date2(buf);
+ buf += 4;
+ break;
+ case 3:
+ t = interpret_long_date(buf);
+ buf += 8;
+ break;
+ }
+ printf("%s", t ? asctime(localtime(&t)) : "NULL\n");
+ fmt++;
+ while (isdigit(*fmt))
+ fmt++;
+ break;
+ }
+ default:
+ putchar(*fmt);
+ fmt++;
+ break;
}
- printf("%s",t?asctime(localtime(&t)):"NULL\n");
- fmt++; while (isdigit(*fmt)) fmt++;
- break;
- }
- default:
- putchar(*fmt);
- fmt++;
- break;
}
- }
- if (buf>=maxbuf && *fmt)
- printf("END OF BUFFER\n");
+ if (buf >= maxbuf && *fmt)
+ printf("END OF BUFFER\n");
- return(buf);
+ return(buf);
trunc:
- printf("\n");
- printf("WARNING: Short packet. Try increasing the snap length\n");
- return(NULL);
+ printf("\n");
+ printf("WARNING: Short packet. Try increasing the snap length\n");
+ return(NULL);
}
-const uchar *fdata(const uchar *buf, const char *fmt, const uchar *maxbuf)
+const uchar *
+fdata(const uchar *buf, const char *fmt, const uchar *maxbuf)
{
- static int depth=0;
- char s[128];
- char *p;
-
- while (*fmt) {
- switch (*fmt) {
- case '*':
- fmt++;
- while (buf < maxbuf) {
- const uchar *buf2;
- depth++;
- buf2 = fdata(buf,fmt,maxbuf);
- depth--;
- if (buf2 == buf) return(buf);
- buf = buf2;
- }
- break;
-
- case '|':
- fmt++;
- if (buf>=maxbuf) return(buf);
- break;
-
- case '%':
- fmt++;
- buf=maxbuf;
- break;
-
- case '#':
- fmt++;
- return(buf);
- break;
-
- case '[':
- fmt++;
- if (buf>=maxbuf) return(buf);
- memset(s, 0, sizeof(s));
- p = strchr(fmt,']');
- strncpy(s,fmt,p-fmt);
- fmt = p+1;
- buf = fdata1(buf,s,maxbuf);
- if (buf == NULL)
- return(NULL);
- break;
-
- default:
- putchar(*fmt); fmt++;
- fflush(stdout);
- break;
+ static int depth = 0;
+ char s[128];
+ char *p;
+
+ while (*fmt) {
+ switch (*fmt) {
+ case '*':
+ fmt++;
+ while (buf < maxbuf) {
+ const uchar *buf2;
+ depth++;
+ buf2 = fdata(buf, fmt, maxbuf);
+ depth--;
+ if (buf2 == buf)
+ return(buf);
+ buf = buf2;
+ }
+ break;
+
+ case '|':
+ fmt++;
+ if (buf >= maxbuf)
+ return(buf);
+ break;
+
+ case '%':
+ fmt++;
+ buf = maxbuf;
+ break;
+
+ case '#':
+ fmt++;
+ return(buf);
+ break;
+
+ case '[':
+ fmt++;
+ if (buf >= maxbuf)
+ return(buf);
+ memset(s, 0, sizeof(s));
+ p = strchr(fmt, ']');
+ if (p - fmt + 1 > sizeof(s)) {
+ /* overrun */
+ return(buf);
+ }
+ strncpy(s, fmt, p - fmt);
+ s[p - fmt] = '\0';
+ fmt = p + 1;
+ buf = fdata1(buf, s, maxbuf);
+ if (buf == NULL)
+ return(NULL);
+ break;
+
+ default:
+ putchar(*fmt);
+ fmt++;
+ fflush(stdout);
+ break;
+ }
}
- }
- if (!depth && buf<maxbuf) {
- int len = PTR_DIFF(maxbuf,buf);
- printf("Data: (%d bytes)\n",len);
- print_data(buf,len);
- return(buf+len);
- }
- return(buf);
+ if (!depth && buf < maxbuf) {
+ size_t len = PTR_DIFF(maxbuf, buf);
+ printf("Data: (%lu bytes)\n", (unsigned long)len);
+ print_data(buf, len);
+ return(buf + len);
+ }
+ return(buf);
}
-typedef struct
-{
- char *name;
- int code;
- char *message;
+typedef struct {
+ char *name;
+ int code;
+ char *message;
} err_code_struct;
/* Dos Error Messages */
static err_code_struct dos_msgs[] = {
- {"ERRbadfunc",1,"Invalid function."},
- {"ERRbadfile",2,"File not found."},
- {"ERRbadpath",3,"Directory invalid."},
- {"ERRnofids",4,"No file descriptors available"},
- {"ERRnoaccess",5,"Access denied."},
- {"ERRbadfid",6,"Invalid file handle."},
- {"ERRbadmcb",7,"Memory control blocks destroyed."},
- {"ERRnomem",8,"Insufficient server memory to perform the requested function."},
- {"ERRbadmem",9,"Invalid memory block address."},
- {"ERRbadenv",10,"Invalid environment."},
- {"ERRbadformat",11,"Invalid format."},
- {"ERRbadaccess",12,"Invalid open mode."},
- {"ERRbaddata",13,"Invalid data."},
- {"ERR",14,"reserved."},
- {"ERRbaddrive",15,"Invalid drive specified."},
- {"ERRremcd",16,"A Delete Directory request attempted to remove the server's current directory."},
- {"ERRdiffdevice",17,"Not same device."},
- {"ERRnofiles",18,"A File Search command can find no more files matching the specified criteria."},
- {"ERRbadshare",32,"The sharing mode specified for an Open conflicts with existing FIDs on the file."},
- {"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
- {"ERRfilexists",80,"The file named in a Create Directory, Make New File or Link request already exists."},
- {"ERRbadpipe",230,"Pipe invalid."},
- {"ERRpipebusy",231,"All instances of the requested pipe are busy."},
- {"ERRpipeclosing",232,"Pipe close in progress."},
- {"ERRnotconnected",233,"No process on other end of pipe."},
- {"ERRmoredata",234,"There is more data to be returned."},
- {NULL,-1,NULL}};
+ { "ERRbadfunc", 1, "Invalid function." },
+ { "ERRbadfile", 2, "File not found." },
+ { "ERRbadpath", 3, "Directory invalid." },
+ { "ERRnofids", 4, "No file descriptors available" },
+ { "ERRnoaccess", 5, "Access denied." },
+ { "ERRbadfid", 6, "Invalid file handle." },
+ { "ERRbadmcb", 7, "Memory control blocks destroyed." },
+ { "ERRnomem", 8, "Insufficient server memory to perform the requested function." },
+ { "ERRbadmem", 9, "Invalid memory block address." },
+ { "ERRbadenv", 10, "Invalid environment." },
+ { "ERRbadformat", 11, "Invalid format." },
+ { "ERRbadaccess", 12, "Invalid open mode." },
+ { "ERRbaddata", 13, "Invalid data." },
+ { "ERR", 14, "reserved." },
+ { "ERRbaddrive", 15, "Invalid drive specified." },
+ { "ERRremcd", 16, "A Delete Directory request attempted to remove the server's current directory." },
+ { "ERRdiffdevice", 17, "Not same device." },
+ { "ERRnofiles", 18, "A File Search command can find no more files matching the specified criteria." },
+ { "ERRbadshare", 32, "The sharing mode specified for an Open conflicts with existing FIDs on the file." },
+ { "ERRlock", 33, "A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process." },
+ { "ERRfilexists", 80, "The file named in a Create Directory, Make New File or Link request already exists." },
+ { "ERRbadpipe", 230, "Pipe invalid." },
+ { "ERRpipebusy", 231, "All instances of the requested pipe are busy." },
+ { "ERRpipeclosing", 232, "Pipe close in progress." },
+ { "ERRnotconnected", 233, "No process on other end of pipe." },
+ { "ERRmoredata", 234, "There is more data to be returned." },
+ { NULL, -1, NULL }
+ };
/* Server Error Messages */
err_code_struct server_msgs[] = {
- {"ERRerror",1,"Non-specific error code."},
- {"ERRbadpw",2,"Bad password - name/password pair in a Tree Connect or Session Setup are invalid."},
- {"ERRbadtype",3,"reserved."},
- {"ERRaccess",4,"The requester does not have the necessary access rights within the specified context for the requested function. The context is defined by the TID or the UID."},
- {"ERRinvnid",5,"The tree ID (TID) specified in a command was invalid."},
- {"ERRinvnetname",6,"Invalid network name in tree connect."},
- {"ERRinvdevice",7,"Invalid device - printer request made to non-printer connection or non-printer request made to printer connection."},
- {"ERRqfull",49,"Print queue full (files) -- returned by open print file."},
- {"ERRqtoobig",50,"Print queue full -- no space."},
- {"ERRqeof",51,"EOF on print queue dump."},
- {"ERRinvpfid",52,"Invalid print file FID."},
- {"ERRsmbcmd",64,"The server did not recognize the command received."},
- {"ERRsrverror",65,"The server encountered an internal error, e.g., system file unavailable."},
- {"ERRfilespecs",67,"The file handle (FID) and pathname parameters contained an invalid combination of values."},
- {"ERRreserved",68,"reserved."},
- {"ERRbadpermits",69,"The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute."},
- {"ERRreserved",70,"reserved."},
- {"ERRsetattrmode",71,"The attribute mode in the Set File Attribute request is invalid."},
- {"ERRpaused",81,"Server is paused."},
- {"ERRmsgoff",82,"Not receiving messages."},
- {"ERRnoroom",83,"No room to buffer message."},
- {"ERRrmuns",87,"Too many remote user names."},
- {"ERRtimeout",88,"Operation timed out."},
- {"ERRnoresource",89,"No resources currently available for request."},
- {"ERRtoomanyuids",90,"Too many UIDs active on this session."},
- {"ERRbaduid",91,"The UID is not known as a valid ID on this session."},
- {"ERRusempx",250,"Temp unable to support Raw, use MPX mode."},
- {"ERRusestd",251,"Temp unable to support Raw, use standard read/write."},
- {"ERRcontmpx",252,"Continue in MPX mode."},
- {"ERRreserved",253,"reserved."},
- {"ERRreserved",254,"reserved."},
- {"ERRnosupport",0xFFFF,"Function not supported."},
- {NULL,-1,NULL}};
+ { "ERRerror", 1, "Non-specific error code." },
+ { "ERRbadpw", 2, "Bad password - name/password pair in a Tree Connect or Session Setup are invalid." },
+ { "ERRbadtype", 3, "reserved." },
+ { "ERRaccess", 4, "The requester does not have the necessary access rights within the specified context for the requested function. The context is defined by the TID or the UID." },
+ { "ERRinvnid", 5, "The tree ID (TID) specified in a command was invalid." },
+ { "ERRinvnetname", 6, "Invalid network name in tree connect." },
+ { "ERRinvdevice", 7, "Invalid device - printer request made to non-printer connection or non-printer request made to printer connection." },
+ { "ERRqfull", 49, "Print queue full (files) -- returned by open print file." },
+ { "ERRqtoobig", 50, "Print queue full -- no space." },
+ { "ERRqeof", 51, "EOF on print queue dump." },
+ { "ERRinvpfid", 52, "Invalid print file FID." },
+ { "ERRsmbcmd", 64, "The server did not recognize the command received." },
+ { "ERRsrverror", 65, "The server encountered an internal error, e.g., system file unavailable." },
+ { "ERRfilespecs", 67, "The file handle (FID) and pathname parameters contained an invalid combination of values." },
+ { "ERRreserved", 68, "reserved." },
+ { "ERRbadpermits", 69, "The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute." },
+ { "ERRreserved", 70, "reserved." },
+ { "ERRsetattrmode", 71, "The attribute mode in the Set File Attribute request is invalid." },
+ { "ERRpaused", 81, "Server is paused." },
+ { "ERRmsgoff", 82, "Not receiving messages." },
+ { "ERRnoroom", 83, "No room to buffer message." },
+ { "ERRrmuns", 87, "Too many remote user names." },
+ { "ERRtimeout", 88, "Operation timed out." },
+ { "ERRnoresource", 89, "No resources currently available for request." },
+ { "ERRtoomanyuids", 90, "Too many UIDs active on this session." },
+ { "ERRbaduid", 91, "The UID is not known as a valid ID on this session." },
+ { "ERRusempx", 250, "Temp unable to support Raw, use MPX mode." },
+ { "ERRusestd", 251, "Temp unable to support Raw, use standard read/write." },
+ { "ERRcontmpx", 252, "Continue in MPX mode." },
+ { "ERRreserved", 253, "reserved." },
+ { "ERRreserved", 254, "reserved." },
+ { "ERRnosupport", 0xFFFF, "Function not supported." },
+ { NULL, -1, NULL }
+};
/* Hard Error Messages */
err_code_struct hard_msgs[] = {
- {"ERRnowrite",19,"Attempt to write on write-protected diskette."},
- {"ERRbadunit",20,"Unknown unit."},
- {"ERRnotready",21,"Drive not ready."},
- {"ERRbadcmd",22,"Unknown command."},
- {"ERRdata",23,"Data error (CRC)."},
- {"ERRbadreq",24,"Bad request structure length."},
- {"ERRseek",25 ,"Seek error."},
- {"ERRbadmedia",26,"Unknown media type."},
- {"ERRbadsector",27,"Sector not found."},
- {"ERRnopaper",28,"Printer out of paper."},
- {"ERRwrite",29,"Write fault."},
- {"ERRread",30,"Read fault."},
- {"ERRgeneral",31,"General failure."},
- {"ERRbadshare",32,"A open conflicts with an existing open."},
- {"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
- {"ERRwrongdisk",34,"The wrong disk was found in a drive."},
- {"ERRFCBUnavail",35,"No FCBs are available to process request."},
- {"ERRsharebufexc",36,"A sharing buffer has been exceeded."},
- {NULL,-1,NULL}};
-
-
-static struct
-{
- int code;
- char *class;
- err_code_struct *err_msgs;
+ { "ERRnowrite", 19, "Attempt to write on write-protected diskette." },
+ { "ERRbadunit", 20, "Unknown unit." },
+ { "ERRnotready", 21, "Drive not ready." },
+ { "ERRbadcmd", 22, "Unknown command." },
+ { "ERRdata", 23, "Data error (CRC)." },
+ { "ERRbadreq", 24, "Bad request structure length." },
+ { "ERRseek", 25 , "Seek error." },
+ { "ERRbadmedia", 26, "Unknown media type." },
+ { "ERRbadsector", 27, "Sector not found." },
+ { "ERRnopaper", 28, "Printer out of paper." },
+ { "ERRwrite", 29, "Write fault." },
+ { "ERRread", 30, "Read fault." },
+ { "ERRgeneral", 31, "General failure." },
+ { "ERRbadshare", 32, "A open conflicts with an existing open." },
+ { "ERRlock", 33, "A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process." },
+ { "ERRwrongdisk", 34, "The wrong disk was found in a drive." },
+ { "ERRFCBUnavail", 35, "No FCBs are available to process request." },
+ { "ERRsharebufexc", 36, "A sharing buffer has been exceeded." },
+ { NULL, -1, NULL }
+};
+
+static struct {
+ int code;
+ char *class;
+ err_code_struct *err_msgs;
} err_classes[] = {
- {0,"SUCCESS",NULL},
- {0x01,"ERRDOS",dos_msgs},
- {0x02,"ERRSRV",server_msgs},
- {0x03,"ERRHRD",hard_msgs},
- {0x04,"ERRXOS",NULL},
- {0xE1,"ERRRMX1",NULL},
- {0xE2,"ERRRMX2",NULL},
- {0xE3,"ERRRMX3",NULL},
- {0xFF,"ERRCMD",NULL},
- {-1,NULL,NULL}};
+ { 0, "SUCCESS", NULL },
+ { 0x01, "ERRDOS", dos_msgs },
+ { 0x02, "ERRSRV", server_msgs },
+ { 0x03, "ERRHRD", hard_msgs },
+ { 0x04, "ERRXOS", NULL },
+ { 0xE1, "ERRRMX1", NULL },
+ { 0xE2, "ERRRMX2", NULL },
+ { 0xE3, "ERRRMX3", NULL },
+ { 0xFF, "ERRCMD", NULL },
+ { -1, NULL, NULL }
+};
-
-/****************************************************************************
-return a SMB error string from a SMB buffer
-****************************************************************************/
-char *smb_errstr(int class,int num)
+/*
+ * return a SMB error string from a SMB buffer
+ */
+char *
+smb_errstr(int class, int num)
{
- static char ret[128];
- int i,j;
-
- ret[0]=0;
-
- for (i=0;err_classes[i].class;i++)
- if (err_classes[i].code == class)
- {
- if (err_classes[i].err_msgs)
- {
- err_code_struct *err = err_classes[i].err_msgs;
- for (j=0;err[j].name;j++)
- if (num == err[j].code)
- {
- snprintf(ret,sizeof(ret),"%s - %s (%s)",err_classes[i].class,
- err[j].name,err[j].message);
- return ret;
- }
- }
-
- snprintf(ret,sizeof(ret),"%s - %d",err_classes[i].class,num);
- return ret;
- }
+ static char ret[128];
+ int i, j;
+
+ ret[0] = 0;
+
+ for (i = 0; err_classes[i].class; i++)
+ if (err_classes[i].code == class) {
+ if (err_classes[i].err_msgs) {
+ err_code_struct *err = err_classes[i].err_msgs;
+ for (j = 0; err[j].name; j++)
+ if (num == err[j].code) {
+ snprintf(ret, sizeof(ret), "%s - %s (%s)",
+ err_classes[i].class, err[j].name, err[j].message);
+ return ret;
+ }
+ }
+
+ snprintf(ret, sizeof(ret), "%s - %d", err_classes[i].class, num);
+ return ret;
+ }
- snprintf(ret,sizeof(ret),"ERROR: Unknown error (%d,%d)",class,num);
- return(ret);
+ snprintf(ret, sizeof(ret), "ERROR: Unknown error (%d,%d)", class, num);
+ return(ret);
}