Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: usr.sbin/ldpd warns about uninitialized object



On Tue, Dec 14, 2010 at 11:58:02AM +0100, Piotr Meyer wrote:

> Regardless of style - it's working, but some time after that, build process 
> stops in another place:
> 
> /usr/src/tests/rump/rumpvfs/t_p2kifs.c: In function 'atfu_makecn_body':
> /usr/src/tests/rump/rumpvfs/t_p2kifs.c:82: warning: call to 
> __builtin___strcpy_chk will always overflow destination buffer

And following path puts it away:

--- t_p2kifs.c.orig     2010-12-14 20:53:38.000000000 +0100
+++ t_p2kifs.c  2010-12-14 20:48:58.000000000 +0100
@@ -54,11 +54,12 @@
 ATF_TC_BODY(makecn, tc)
 {
        struct componentname *cn;
-       char pathstr[] = TESTFILE;
+       char pathstr[256];
        struct vnode *vp;
        extern struct vnode *rumpns_rootvnode;

        rump_init();
+       strncpy(pathstr, TESTFILE, sizeof(pathstr));

        /*
         * Strategy is to create a componentname, edit the passed
@@ -79,7 +80,7 @@
        /* and then with modification-in-the-middle */
        cn = rump_pub_makecn(RUMP_NAMEI_LOOKUP, 0, pathstr, strlen(pathstr),
            rump_pub_cred_create(0, 0, 0, NULL), rump_pub_lwproc_curlwp());
-       strcpy(pathstr, "/muuta");
+       strncpy(pathstr, "/muuta", sizeof(pathstr));
        RZ(RUMP_VOP_LOOKUP(rumpns_rootvnode, &vp, cn));
        RUMP_VOP_UNLOCK(vp);
        rump_pub_freecn(cn, RUMPCN_FREECRED);


-- 
Piotr 'aniou' Meyer


Home | Main Index | Thread Index | Old Index