r22042: Try and clean up my own mess using the API Volker
[samba.git] / source3 / nmbd / nmbd_incomingdgrams.c
index 53b19471572b15deb8dc68d6ae9fb0fb614bfb69..ec8aa370ce3e19edfa67fff4240ba721e0572e3f 100644 (file)
@@ -108,7 +108,6 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p
        START_PROFILE(host_announce);
 
        pull_ascii_fstring(comment, buf+31);
-       comment[42] = 0;
   
        pull_ascii_nstring(announce_name, sizeof(announce_name), buf+5);
        pull_ascii_nstring(source_name, sizeof(source_name), dgram->source_name.name);
@@ -267,7 +266,6 @@ void process_local_master_announce(struct subnet_record *subrec, struct packet_s
 
        pull_ascii_nstring(server_name,sizeof(server_name),buf+5);
        pull_ascii_fstring(comment, buf+31);
-       comment[42] = 0;
        pull_ascii_nstring(source_name, sizeof(source_name), dgram->source_name.name);
        pull_ascii_nstring(work_name, sizeof(work_name), dgram->dest_name.name);
 
@@ -418,7 +416,7 @@ done:
   Process an incoming LanMan host announcement packet.
 *******************************************************************/
 
-void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf)
+void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len)
 {
        struct dgram_packet *dgram = &p->packet.dgram;
        uint32 servertype = IVAL(buf,1);
@@ -431,10 +429,16 @@ void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct
        unstring work_name;
        unstring source_name;
        fstring comment;
-       char *s = buf+9;
+       char *s = get_safe_str_ptr(buf,len,buf,9);
 
        START_PROFILE(lm_host_announce);
-       s = skip_string(s,1);
+       if (!s) {
+               goto done;
+       }
+       s = skip_string(buf,len,s,1);
+       if (!s) {
+               goto done;
+       }
        pull_ascii(comment, s, sizeof(fstring), 43, STR_TERMINATE);
 
        pull_ascii_nstring(announce_name,sizeof(announce_name),buf+9);
@@ -570,7 +574,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
        myname[15]='\0';
        push_pstring_base(p, myname, outbuf);
 
-       p = skip_string(p,1);
+       p = skip_string(outbuf,sizeof(outbuf),p,1);
 
        /* Look for backup browsers in this workgroup. */
 
@@ -606,7 +610,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
     DEBUG(5,("send_backup_list_response: Adding server %s number %d\n",
               p, count));
 
-    p = skip_string(p,1);
+    p = skip_string(outbuf,sizeof(outbuf),p,1);
   }
 #endif
 
@@ -799,7 +803,7 @@ void process_announce_request(struct subnet_record *subrec, struct packet_struct
        work->needannounce = True;
 done:
 
-       END_PROFILE(lm_host_announce);
+       END_PROFILE(announce_request);
 }
 
 /*******************************************************************
@@ -811,7 +815,7 @@ done:
   through the "lm announce" parameter in smb.conf)
 ******************************************************************/
 
-void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf)
+void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len)
 {
        struct dgram_packet *dgram = &p->packet.dgram;
        unstring workgroup_name;
@@ -840,5 +844,5 @@ void process_lm_announce_request(struct subnet_record *subrec, struct packet_str
 
 done:
 
-       END_PROFILE(lm_host_announce);
+       END_PROFILE(lm_announce_request);
 }