summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-06-24 19:02:37 +0000
committerLuke Leighton <lkcl@samba.org>1999-06-24 19:02:37 +0000
commitf63e8070488e079c899cde90e8452796f3af4e5f (patch)
tree71911f988b79d2a019f04d50d082df58c55ee0c9 /source3
parentcae3620b2e8abbe35f0369a82d5461cb596475a3 (diff)
downloadsamba-f63e8070488e079c899cde90e8452796f3af4e5f.tar.gz
samba-f63e8070488e079c899cde90e8452796f3af4e5f.tar.bz2
samba-f63e8070488e079c899cde90e8452796f3af4e5f.zip
safe string version of nmb_namestr.
(This used to be commit 250621b3cec5fc463d348432d1d0ff5fb59e7a29)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h1
-rw-r--r--source3/libsmb/nmblib.c17
2 files changed, 14 insertions, 4 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index cca2a6be79..361eda72b5 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -722,6 +722,7 @@ BOOL find_master_ip(char *group, struct in_addr *master_ip);
void debug_nmb_packet(struct packet_struct *p);
char *nmb_namestr(struct nmb_name *n);
+void nmb_safe_namestr(struct nmb_name *n, char *str, size_t len);
struct packet_struct *copy_packet(struct packet_struct *packet);
void free_packet(struct packet_struct *packet);
struct packet_struct *read_packet(int fd,enum packet_type packet_type);
diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c
index 14dc5ecee2..54b1779f44 100644
--- a/source3/libsmb/nmblib.c
+++ b/source3/libsmb/nmblib.c
@@ -287,6 +287,7 @@ static int put_nmb_name(char *buf,int offset,struct nmb_name *name)
return(ret);
}
+
/*******************************************************************
useful for debugging messages
******************************************************************/
@@ -296,16 +297,24 @@ char *nmb_namestr(struct nmb_name *n)
static fstring ret[4];
char *p = ret[i];
- if (!n->scope[0])
- slprintf(p,sizeof(fstring)-1, "%s<%02x>",n->name,n->name_type);
- else
- slprintf(p,sizeof(fstring)-1, "%s<%02x>.%s",n->name,n->name_type,n->scope);
+ nmb_safe_namestr(n, p, sizeof(fstring));
i = (i+1)%4;
return(p);
}
/*******************************************************************
+ useful for debugging messages
+ ******************************************************************/
+void nmb_safe_namestr(struct nmb_name *n, char *str, size_t len)
+{
+ if (!n->scope[0])
+ slprintf(str, len-1, "%s<%02x>",n->name,n->name_type);
+ else
+ slprintf(str, len-1, "%s<%02x>.%s",n->name,n->name_type,n->scope);
+}
+
+/*******************************************************************
allocate and parse some resource records
******************************************************************/
static BOOL parse_alloc_res_rec(char *inbuf,int *offset,int length,