Back to success stories

Sample of Defect

Project Name CID Checker Category Developer Description
elbing/harvey 91319 UNINIT Uninitialized variables This has been there for decade, and was shipped in a real product. And nobody every found it.
File: /sys/src/9/port/devaoe.c
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
        size = 0;
        switch(type){
        default:
                return -1;
        case Qtopctl:
                p = "ctl";
                perm = 0644;
                break;
        case Qtoplog:
                p = "log";
                size = eventcount();
                break;
        }
        mkqid(&q, type, 0, QTFILE);
        devdir(c, q, p, size, eve, perm, d);
        return 1;
}

static int
aoegen(Chan *c, char *e, Dirtab *dir, int j, int s, Dir *dp)
{
        Mach *m = machp();
        int i;
        Aoedev *d;
 << 1. Declaring variable "q" without initializer.
848
        Qid q;
 < 2. Condition "c->qid.path == 0", taking true branch
850
        if(c->qid.path == 0){
 < 3. Switch case value "-1"
851
852
853
854
                switch(s){
                case DEVDOTDOT:
                        q.path = 0;
                        q.type = QTDIR;
 <<< CID 91319: Uninitialized variables UNINIT
 <<< 4. Using uninitialized value "q". Field "q.vers" is uninitialized when calling "devdir".
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
                        devdir(c, q, "", 0, eve, 0555, dp);
                        break;
                case 0:
                        q.path = Qtopdir;
                        q.type = QTDIR;
                        devdir(c, q, "aoe", 0, eve, 0555, dp);
                        break;
                default:
                        return -1;
                }
                return 1;
        }

        switch(TYPE(c->qid)){
        default:
                return -1;
        case Qtopdir:
                if(s == DEVDOTDOT){
                        mkqid(&q, Qzero, 0, QTDIR);
                        devdir(c, q, "aoe", 0, eve, 0555, dp);
                        return 1;
                }
                if(s < Qtopfiles)
                        return topgen(c, Qtopbase + s, dp);
                s -= Qtopfiles;
                if(s >= units.ref)
                        return -1;
Events:
1. var_decl devaoe.c:848
4. uninit_use_in_call devaoe.c:855