summaryrefslogtreecommitdiff
path: root/source3/nmbd/nmbd_processlogon.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-09-19 17:52:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:30:53 -0500
commit934b92f5d0e4950f7b4c7531eecf3df59a4d0ed3 (patch)
treee12058b067c04da324daa226a7f77c675caa5694 /source3/nmbd/nmbd_processlogon.c
parent0805a4bc715f055fd68c5e27bd46eadfb101e1b9 (diff)
downloadsamba-934b92f5d0e4950f7b4c7531eecf3df59a4d0ed3.tar.gz
samba-934b92f5d0e4950f7b4c7531eecf3df59a4d0ed3.tar.bz2
samba-934b92f5d0e4950f7b4c7531eecf3df59a4d0ed3.zip
r25238: Make the error returns from the string functions
always consistent. Return -1 on error, and ensure we check for this. In cases where the dest is already specified and we've been asked to terminate with a null, ensure we always do so even on error. Jeremy. (This used to be commit abedd967869ade9a43c3a8e1b889c60d4aca81cf)
Diffstat (limited to 'source3/nmbd/nmbd_processlogon.c')
-rw-r--r--source3/nmbd/nmbd_processlogon.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c
index 8a183c4d24..abac2ac776 100644
--- a/source3/nmbd/nmbd_processlogon.c
+++ b/source3/nmbd/nmbd_processlogon.c
@@ -53,6 +53,7 @@ void process_logon_packet(struct packet_struct *p, char *buf,int len,
char *uniuser; /* Unicode user name. */
pstring ascuser;
char *unicomp; /* Unicode computer name. */
+ size_t size;
memset(outbuf, 0, sizeof(outbuf));
@@ -108,9 +109,12 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
fstrcpy(reply_name, "\\\\");
fstrcat(reply_name, my_name);
- push_ascii(q,reply_name,
+ size = push_ascii(q,reply_name,
sizeof(outbuf)-PTR_DIFF(q, outbuf),
STR_TERMINATE);
+ if (size == (size_t)-1) {
+ return;
+ }
q = skip_string(outbuf,sizeof(outbuf),q); /* PDC name */
SSVAL(q, 0, token);
@@ -206,9 +210,12 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
q += 2;
fstrcpy(reply_name,my_name);
- push_ascii(q, reply_name,
+ size = push_ascii(q, reply_name,
sizeof(outbuf)-PTR_DIFF(q, outbuf),
STR_TERMINATE);
+ if (size == (size_t)-1) {
+ return;
+ }
q = skip_string(outbuf,sizeof(outbuf),q); /* PDC name */
/* PDC and domain name */
@@ -377,7 +384,6 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
pstring domain;
pstring hostname;
char *component, *dc, *q1;
- uint8 size;
char *q_orig = q;
int str_offset;
@@ -423,6 +429,9 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
size = push_ascii(&q[1], component,
sizeof(outbuf) - PTR_DIFF(q+1, outbuf),
0);
+ if (size == (size_t)-1 || size > 0xff) {
+ return;
+ }
SCVAL(q, 0, size);
q += (size + 1);
}
@@ -443,6 +452,9 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
size = push_ascii(&q[1], hostname,
sizeof(outbuf) - PTR_DIFF(q+1, outbuf),
0);
+ if (size == (size_t)-1 || size > 0xff) {
+ return;
+ }
SCVAL(q, 0, size);
q += (size + 1);
@@ -458,6 +470,9 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
size = push_ascii(&q[1], lp_workgroup(),
sizeof(outbuf) - PTR_DIFF(q+1, outbuf),
STR_UPPER);
+ if (size == (size_t)-1 || size > 0xff) {
+ return;
+ }
SCVAL(q, 0, size);
q += (size + 1);
@@ -473,6 +488,9 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
size = push_ascii(&q[1], my_name,
sizeof(outbuf) - PTR_DIFF(q+1, outbuf),
0);
+ if (size == (size_t)-1 || size > 0xff) {
+ return;
+ }
SCVAL(q, 0, size);
q += (size + 1);
@@ -489,6 +507,9 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
size = push_ascii(&q[1], ascuser,
sizeof(outbuf) - PTR_DIFF(q+1, outbuf),
0);
+ if (size == (size_t)-1 || size > 0xff) {
+ return;
+ }
SCVAL(q, 0, size);
q += (size + 1);
}
@@ -501,6 +522,9 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
size = push_ascii(&q[1], "Default-First-Site-Name",
sizeof(outbuf) - PTR_DIFF(q+1, outbuf),
0);
+ if (size == (size_t)-1 || size > 0xff) {
+ return;
+ }
SCVAL(q, 0, size);
q += (size + 1);