aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/smbfs/smbutil/view.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/smbfs/smbutil/view.c')
-rw-r--r--contrib/smbfs/smbutil/view.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/contrib/smbfs/smbutil/view.c b/contrib/smbfs/smbutil/view.c
index e3e600f57e4d..42450df26593 100644
--- a/contrib/smbfs/smbutil/view.c
+++ b/contrib/smbfs/smbutil/view.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, Boris Popov
+ * Copyright (c) 2000-2002, Boris Popov
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: view.c,v 1.8 2001/08/22 03:33:38 bp Exp $
+ * $Id: view.c,v 1.9 2002/02/20 09:26:42 bp Exp $
*/
#include <sys/param.h>
#include <sys/errno.h>
@@ -44,6 +44,8 @@
#include <cflib.h>
+#include <sys/mchain.h>
+
#include <netsmb/smb_lib.h>
#include <netsmb/smb_conn.h>
#include <netsmb/smb_rap.h>
@@ -53,8 +55,8 @@
static char *shtype[] = {
"disk",
"printer",
- "pipe",
- "comm",
+ "comm", /* Communications device */
+ "pipe", /* IPC Inter process communication */
"unknown"
};
@@ -64,7 +66,9 @@ cmd_view(int argc, char *argv[])
struct smb_ctx sctx, *ctx = &sctx;
struct smb_share_info_1 *rpbuf, *ep;
char *cp;
+ u_int16_t type;
int error, opt, bufsize, i, entries, total;
+
if (argc < 2)
view_usage();
@@ -100,7 +104,7 @@ cmd_view(int argc, char *argv[])
}
printf("Share Type Comment\n");
printf("-------------------------------\n");
- bufsize = 65535;
+ bufsize = 0xffe0; /* samba notes win2k bug with 65535 */
rpbuf = malloc(bufsize);
error = smb_rap_NetShareEnum(ctx, 1, rpbuf, bufsize, &entries, &total);
if (error &&
@@ -109,9 +113,11 @@ cmd_view(int argc, char *argv[])
exit(1);
}
for (ep = rpbuf, i = 0; i < entries; i++, ep++) {
+ type = letohs(ep->shi1_type);
+
cp = (char*)rpbuf + ep->shi1_remark;
printf("%-12s %-10s %s\n", ep->shi1_netname,
- shtype[ep->shi1_type],
+ shtype[min(type, sizeof shtype / sizeof(char *) - 1)],
ep->shi1_remark ? nls_str_toloc(cp, cp) : "");
}
printf("\n%d shares listed from %d available\n", entries, total);