Fix warning messages caused by addition of null check in fstrcpy macro.
authorJeremy Allison <jra@samba.org>
Wed, 4 May 2011 18:38:26 +0000 (11:38 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 4 May 2011 19:12:15 +0000 (12:12 -0700)
19 files changed:
source3/client/client.c
source3/groupdb/mapping.c
source3/libnet/libnet_dssync_passdb.c
source3/libnet/libnet_samsync_passdb.c
source3/nmbd/nmbd_browsesync.c
source3/nmbd/nmbd_incomingdgrams.c
source3/nmbd/nmbd_workgroupdb.c
source3/printing/lpq_parse.c
source3/rpc_server/spoolss/srv_spoolss_nt.c
source3/smbd/password.c
source3/smbd/trans2.c
source3/torture/locktest.c
source3/utils/net_groupmap.c
source3/utils/net_rpc.c
source3/utils/smbpasswd.c
source3/winbindd/idmap_hash/mapfile.c
source3/winbindd/wb_fill_pwent.c
source3/winbindd/winbindd_cm.c
source3/winbindd/winbindd_wins.c

index 75d5716..836d101 100644 (file)
@@ -5046,9 +5046,9 @@ static int do_message_op(struct user_auth_info *a_info)
        make_nmb_name(&calling, calling_name, 0x0);
        make_nmb_name(&called , desthost, name_type);
 
-       fstrcpy(server_name, desthost);
+       strlcpy(server_name, desthost,sizeof(server_name));
        snprintf(name_type_hex, sizeof(name_type_hex), "#%X", name_type);
-       fstrcat(server_name, name_type_hex);
+       strlcat(server_name, name_type_hex,sizeof(server_name));
 
         zero_sockaddr(&ss);
        if (have_ip)
index 3646e04..d35f3c5 100644 (file)
@@ -777,8 +777,8 @@ NTSTATUS pdb_create_builtin_alias(uint32 rid)
        map.gid = gid;
        sid_copy(&map.sid, &sid);
        map.sid_name_use = SID_NAME_ALIAS;
-       fstrcpy(map.nt_name, groupname);
-       fstrcpy(map.comment, "");
+       strlcpy(map.nt_name, groupname, sizeof(map.nt_name));
+       strlcpy(map.comment, "", sizeof(map.comment));
 
        status = pdb_add_group_mapping_entry(&map);
 
index ab34756..7380efa 100644 (file)
@@ -1531,11 +1531,11 @@ static NTSTATUS handle_alias_object(struct dssync_passdb *pctx,
                map.sid_name_use = SID_NAME_ALIAS;
        }
 
-       fstrcpy(map.nt_name, name);
+       strlcpy(map.nt_name, name, sizeof(map.nt_name));
        if (description) {
-               fstrcpy(map.comment, comment);
+               strlcpy(map.comment, comment, sizeof(map.comment));
        } else {
-               fstrcpy(map.comment, "");
+               strlcpy(map.comment, "", sizeof(map.comment));
        }
 
        if (insert)
@@ -1636,11 +1636,11 @@ static NTSTATUS handle_group_object(struct dssync_passdb *pctx,
        map.gid = grp->gr_gid;
        map.sid = group_sid;
        map.sid_name_use = SID_NAME_DOM_GRP;
-       fstrcpy(map.nt_name, name);
+       strlcpy(map.nt_name, name, sizeof(map.nt_name));
        if (description) {
-               fstrcpy(map.comment, comment);
+               strlcpy(map.comment, comment, sizeof(map.comment));
        } else {
-               fstrcpy(map.comment, "");
+               strlcpy(map.comment, "", sizeof(map.comment));
        }
 
        if (insert)
index b579723..d8928c8 100644 (file)
@@ -428,11 +428,11 @@ static NTSTATUS fetch_group_info(TALLOC_CTX *mem_ctx,
        map.gid = grp->gr_gid;
        map.sid = group_sid;
        map.sid_name_use = SID_NAME_DOM_GRP;
-       fstrcpy(map.nt_name, name);
+       strlcpy(map.nt_name, name, sizeof(map.nt_name));
        if (r->description.string) {
-               fstrcpy(map.comment, comment);
+               strlcpy(map.comment, comment, sizeof(map.comment));
        } else {
-               fstrcpy(map.comment, "");
+               strlcpy(map.comment, "", sizeof(map.comment));
        }
 
        if (insert)
@@ -617,8 +617,8 @@ static NTSTATUS fetch_alias_info(TALLOC_CTX *mem_ctx,
        else
                map.sid_name_use = SID_NAME_ALIAS;
 
-       fstrcpy(map.nt_name, name);
-       fstrcpy(map.comment, comment);
+       strlcpy(map.nt_name, name, sizeof(map.nt_name));
+       strlcpy(map.comment, comment, sizeof(map.comment));
 
        if (insert)
                pdb_add_group_mapping_entry(&map);
index 4a6f9f2..1a262e4 100644 (file)
@@ -435,7 +435,7 @@ static void get_domain_master_name_node_status_success(struct subnet_record *sub
                        if(!(nb_flags & NB_GROUP) && (name_type == 0x00) && 
                                        server_name[0] == 0) {
                                /* this is almost certainly the server netbios name */
-                               unstrcpy(server_name, qname);
+                               strlcpy(server_name, qname, sizeof(server_name));
                                continue;
                        }
 
@@ -461,7 +461,9 @@ static void get_domain_master_name_node_status_success(struct subnet_record *sub
                                                return;
 
                                        /* remember who the master is */
-                                       unstrcpy(work->local_master_browser_name, server_name);
+                                       strlcpy(work->local_master_browser_name,
+                                               server_name,
+                                               sizeof(work->local_master_browser_name));
                                        make_nmb_name(&nmbname, server_name, 0x20);
                                        work->dmb_name = nmbname;
                                        work->dmb_addr = from_ip;
index 6993e18..d3b9d3d 100644 (file)
@@ -172,7 +172,7 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p
                        /* Update the record. */
                        servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
                        update_server_ttl( servrec, ttl);
-                       fstrcpy(servrec->serv.comment,comment);
+                       strlcpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment));
                }
        } else {
                /*
@@ -338,7 +338,7 @@ a local master browser for workgroup %s and we think we are master. Forcing elec
                        /* Update the record. */
                        servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
                        update_server_ttl(servrec, ttl);
-                       fstrcpy(servrec->serv.comment,comment);
+                       strlcpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment));
                }
        
                set_workgroup_local_master_browser_name( work, server_name );
@@ -512,7 +512,7 @@ originate from OS/2 Warp client. Ignoring packet.\n"));
                        /* Update the record. */
                        servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
                        update_server_ttl( servrec, ttl);
-                       fstrcpy(servrec->serv.comment,comment);
+                       strlcpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment));
                }
        } else {
                /*
index 5ce10e6..819d504 100644 (file)
@@ -52,7 +52,7 @@ static void name_to_unstring(unstring unname, const char *name)
        if (errno == E2BIG) {
                unstring tname;
                pull_ascii_nstring(tname, sizeof(tname), nname);
-               unstrcpy(unname, tname);
+               strlcpy(unname, tname, sizeof(nname));
                DEBUG(0,("name_to_nstring: workgroup name %s is too long. Truncating to %s\n",
                        name, tname));
        } else {
index 16b9b09..9104497 100644 (file)
@@ -801,8 +801,9 @@ static bool parse_lpq_plp(char *line,print_queue_struct *buf,bool first)
                fstring tmp;
                char *p = strrchr_m(tok[6],'/');
                if (p) {
+                       size_t len = strlen(tok[6])+1;
                        fstrcpy(tmp,p+1);
-                       fstrcpy(tok[6],tmp);
+                       strlcpy(tok[6],tmp, len);
                }
        }
 
index 02587ca..c50e284 100644 (file)
@@ -727,7 +727,7 @@ static WERROR set_printer_hnd_name(TALLOC_CTX *mem_ctx,
 
        DEBUGADD(4,("set_printer_hnd_name: Printer found: %s -> %s\n", aprinter, sname));
 
-       fstrcpy(Printer->sharename, sname);
+       strlcpy(Printer->sharename, sname, sizeof(Printer->sharename));
 
        return WERR_OK;
 }
index 54746c3..3438434 100644 (file)
@@ -644,7 +644,7 @@ bool authorise_login(struct smbd_server_connection *sconn,
                                        get_session_workgroup(sconn),
                                        user2,password)) {
                                ok = True;
-                               fstrcpy(user,user2);
+                               strlcpy(user,user2,sizeof(user));
                                DEBUG(3,("authorise_login: ACCEPTED: session "
                                         "list username (%s) and given "
                                         "password ok\n", user));
@@ -695,7 +695,7 @@ bool authorise_login(struct smbd_server_connection *sconn,
                                                get_session_workgroup(sconn),
                                                user2,password)) {
                                        ok = True;
-                                       fstrcpy(user,user2);
+                                       strlcpy(user,user2,sizeof(user));
                                        DEBUG(3,("authorise_login: ACCEPTED: "
                                                 "user list username and "
                                                 "given password ok (%s)\n",
@@ -714,7 +714,7 @@ bool authorise_login(struct smbd_server_connection *sconn,
                fstrcpy(guestname,lp_guestaccount());
                guest_pw = Get_Pwnam_alloc(talloc_tos(), guestname);
                if (guest_pw != NULL) {
-                       fstrcpy(user,guestname);
+                       strlcpy(user,guestname,sizeof(user));
                        ok = True;
                        DEBUG(3,("authorise_login: ACCEPTED: guest account "
                                 "and guest ok (%s)\n", user));
index 39e653a..7c8b43c 100644 (file)
@@ -388,7 +388,7 @@ static unsigned int fill_ea_buffer(TALLOC_CTX *mem_ctx, char *pdata, unsigned in
                SCVAL(p,0,ea_list->ea.flags);
                SCVAL(p,1,dos_namelen);
                SSVAL(p,2,ea_list->ea.value.length);
-               fstrcpy(p+4, dos_ea_name);
+               strlcpy(p+4, dos_ea_name, dos_namelen+1);
                memcpy( p + 4 + dos_namelen + 1, ea_list->ea.value.data, ea_list->ea.value.length);
 
                total_data_size -= 4 + dos_namelen + 1 + ea_list->ea.value.length;
@@ -452,7 +452,7 @@ static NTSTATUS fill_ea_chained_buffer(TALLOC_CTX *mem_ctx,
                SCVAL(p, 0x04, ea_list->ea.flags);
                SCVAL(p, 0x05, dos_namelen);
                SSVAL(p, 0x06, ea_list->ea.value.length);
-               fstrcpy((char *)(p+0x08), dos_ea_name);
+               strlcpy((char *)(p+0x08), dos_ea_name, dos_namelen+1);
                memcpy(p + 0x08 + dos_namelen + 1, ea_list->ea.value.data, ea_list->ea.value.length);
 
                total_data_size -= this_size;
index 27e3a13..2420990 100644 (file)
@@ -232,8 +232,8 @@ static struct cli_state *connect_one(char *share, int snum)
        }
 
        if (got_pass == 1) {
-               fstrcpy(password[1], password[0]);
-               fstrcpy(username[1], username[0]);
+               strlcpy(password[1], password[0],sizeof(password[1]));
+               strlcpy(username[1], username[0],sizeof(username[1]));
        }
 
        status = cli_session_setup(c, username[snum],
index 818905e..9145093 100644 (file)
@@ -130,7 +130,7 @@ static int net_groupmap_list(struct net_context *c, int argc, const char **argv)
                GROUP_MAP map;
 
                if ( sid_string[0] )
-                       fstrcpy( ntgroup, sid_string);
+                       strlcpy(ntgroup, sid_string, sizeof(ntgroup));
 
                if (!get_sid_from_input(&sid, ntgroup)) {
                        return -1;
@@ -324,7 +324,7 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
        }
 
        if (!ntgroup[0] )
-               fstrcpy( ntgroup, unixgrp );
+               strlcpy(ntgroup, unixgrp, sizeof(ntgroup));
 
        if (!NT_STATUS_IS_OK(add_initial_entry(gid, string_sid, sid_type, ntgroup, ntcomment))) {
                d_fprintf(stderr, _("adding entry for group %s failed!\n"), ntgroup);
@@ -457,10 +457,10 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
 
        /* Change comment if new one */
        if ( ntcomment[0] )
-               fstrcpy( map.comment, ntcomment );
+               strlcpy(map.comment, ntcomment, sizeof(map.comment));
 
        if ( ntgroup[0] )
-               fstrcpy( map.nt_name, ntgroup );
+               strlcpy(map.nt_name, ntgroup, sizeof(map.nt_name));
 
        if ( unixgrp[0] ) {
                gid = nametogid( unixgrp );
@@ -528,7 +528,7 @@ static int net_groupmap_delete(struct net_context *c, int argc, const char **arg
        /* give preference to the SID if we have that */
 
        if ( sid_string[0] )
-               fstrcpy( ntgroup, sid_string );
+               strlcpy(ntgroup, sid_string, sizeof(ntgroup));
 
        if ( !get_sid_from_input(&sid, ntgroup) ) {
                d_fprintf(stderr, _("Unable to resolve group %s to a SID\n"),
index a365726..4339852 100644 (file)
@@ -3763,8 +3763,8 @@ static NTSTATUS copy_fn(const char *mnt, struct file_info *f,
                }
 
                /* search below that directory */
-               fstrcpy(new_mask, dir);
-               fstrcat(new_mask, "\\*");
+               strlcpy(new_mask, dir, sizeof(new_mask));
+               strlcat(new_mask, "\\*", sizeof(new_mask));
 
                old_dir = local_state->cwd;
                local_state->cwd = dir;
@@ -4802,7 +4802,7 @@ static bool get_user_tokens_from_file(FILE *f,
 
                token = &((*tokens)[*num_tokens-1]);
 
-               fstrcpy(token->name, line);
+               strlcpy(token->name, line, sizeof(token->name));
                token->token.num_sids = 0;
                token->token.sids = NULL;
                continue;
index ada057c..8c78049 100644 (file)
@@ -378,7 +378,7 @@ static int process_root(int local_flags)
                 */
 
                slprintf(buf, sizeof(buf)-1, "%s$", user_name);
-               fstrcpy(user_name, buf);
+               strlcpy(user_name, buf, sizeof(user_name));
        } else if (local_flags & LOCAL_INTERDOM_ACCOUNT) {
                static fstring buf;
 
@@ -395,7 +395,7 @@ static int process_root(int local_flags)
 
                /* prepare uppercased and '$' terminated username */
                slprintf(buf, sizeof(buf) - 1, "%s$", user_name);
-               fstrcpy(user_name, buf);
+               strlcpy(user_name, buf, sizeof(user_name));
 
        } else {
 
index 2828059..1183328 100644 (file)
@@ -87,8 +87,8 @@ static bool mapfile_read_line(fstring key, fstring value)
        *p = '\0';
        p++;
 
-       fstrcpy(key, buffer);
-       fstrcpy(value, p);
+       strlcpy(key, buffer, sizeof(key));
+       strlcpy(value, p, sizeof(value));
 
        /* Eat whitespace */
 
index 37d4535..6fad5f4 100644 (file)
@@ -131,7 +131,9 @@ static void wb_fill_pwent_sid2gid_done(struct tevent_req *subreq)
                                     true);
        }
 
-       fstrcpy(state->pw->pw_name, output_username);
+       strlcpy(state->pw->pw_name,
+               output_username,
+               sizeof(state->pw->pw_name));
        fstrcpy(state->pw->pw_gecos, state->info->full_name);
 
        /* Home directory and shell */
index bf87742..f5a9e73 100644 (file)
@@ -1549,7 +1549,7 @@ static NTSTATUS cm_open_connection(struct winbindd_domain *domain,
                                return NT_STATUS_UNSUCCESSFUL;
                        }
                        if (dcip_to_name(mem_ctx, domain, &ss, saf_name )) {
-                               fstrcpy( domain->dcname, saf_name );
+                               strlcpy(domain->dcname, saf_name, sizeof(domain->dcname));
                        } else {
                                winbind_add_failed_connection_entry(
                                        domain, saf_servername,
index e1beb1d..5ac6109 100644 (file)
@@ -140,7 +140,9 @@ void winbindd_wins_byip(struct winbindd_cli_state *state)
            response[strlen(response)-1] = '\n';
            TALLOC_FREE(status);
        }
-       fstrcpy(state->response->data.winsresp,response);
+       strlcpy(state->response->data.winsresp,
+                       response,
+                       sizeof(state->response->data.winsresp));
        request_ok(state);
 }
 
@@ -181,8 +183,8 @@ void winbindd_wins_byname(struct winbindd_cli_state *state)
                                        response[strlen(response)-1] = ' ';
                                }
                        }
-                       fstrcat(response,addr);
-                       fstrcat(response,"\t");
+                       strlcat(response,addr,sizeof(response));
+                       strlcat(response,"\t",sizeof(response));
                }
                size = strlen(state->request->data.winsreq) + strlen(response);
                if (size > maxlen) {
@@ -190,15 +192,17 @@ void winbindd_wins_byname(struct winbindd_cli_state *state)
                    request_error(state);
                    return;
                }
-               fstrcat(response,state->request->data.winsreq);
-               fstrcat(response,"\n");
+               strlcat(response,state->request->data.winsreq,sizeof(response));
+               strlcat(response,"\n",sizeof(response));
                TALLOC_FREE(ip_list);
        } else {
                request_error(state);
                return;
        }
 
-       fstrcpy(state->response->data.winsresp,response);
+       strlcpy(state->response->data.winsresp,
+               response,
+               sizeof(state->response->data.winsresp));
 
        request_ok(state);
 }