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 75d57165cf8933865182c0402279eaa713b5947a..836d1016be1c29d2dd07c763765f69467017b018 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 3646e04d0a3e5fd6e372d0de57dcb810e3c49880..d35f3c5f34d01761595543d908d6f360091f11c3 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 ab347567f149b46bceb890b26f5b278ba3f0b421..7380efabb8adc2e3b7c8535b7ea2c2e9652caf10 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 b579723f6fd2c3b0ec107d58036594a01bb11037..d8928c85a68b10b0395984b3ba3015b40c615622 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 4a6f9f2d47d694a1d63b8f6d7a56d1622d154567..1a262e4728e2ad370f2cddf4bff108a2a90edb77 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 6993e183583531e63e422b2801475dc5e51ec39d..d3b9d3d439b7bde0dc66dad41ea95b4869b0e59d 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 5ce10e64d46e8434b439252f30f2aa80aeb72f76..819d5048ad17c79e5a5869a6b89e15817c03389e 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 16b9b09fef32f5f8d136cf0770cd7ecdc2a68abf..9104497f9f663ff8813d068f08bd2a9116da9a74 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 02587cae0dd22b9b5b386195e411125d3532388b..c50e28459366675cc64c6f8f01d2217acb69501c 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 54746c3f56509472fbfe07e46bfb5aa771c1274d..34384342afb7e4e4bdc3f03965bf6fc7f3484f3d 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 39e653afaed3989e51e9949e50355ed8c844486f..7c8b43c10c0b1ffc2cf515952fdccb926d7db2d1 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 27e3a131335d5ea850f8190c833c5a4474710b08..242099092b6ab90735212893cdfd199702af47e9 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 818905e122f3a2f759ac73b97e0f3b3edbe95f96..9145093f52d32c5bd283f9a22f47d6b3358ef8c0 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 a3657262c4dd1642f65095178293b8c5f39c3e37..43398524ec052af959a64874f7c1298bee22f84d 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 ada057c2479c058acc2c521301218deb2d91de44..8c780498b5b393bb3ef7cac13942c1cb4f200054 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 28280590934f95fb242f60709780ce0a2e5fa207..1183328a3f165fb7593e4dbc330daef036eb7b90 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 37d45357db708afc7d6259d350da2d83524ce0e5..6fad5f43605f6b1047d244299a01d9b7fd0409f0 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 bf877429e9c8d17f9b089abbf64ef42dae470967..f5a9e73905dc8b5fed6d14ea18cbfd95a66cc30c 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 e1beb1d80bf6fa89f89e8cfbc81b247f9700358f..5ac6109411239e84aea8b7bb1a1ac6a9f7954046 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);
 }