Travis-CI: clang static analyzer #217

Merged
sjaeckel merged 12 commits from scan-build into develop 2017-06-14 02:19:20 -05:00
sjaeckel commented 2017-05-22 16:14:30 -05:00 (Migrated from github.com)

lulz @ the conversion from issue to PR

... it changes the author of the initial comment... @karel-m wrote all this...

------------------

Although I am not sure how to do it I believe that it might be possible to utilize clang static analyzer in our automated travis builds.

Manually you can start it like:

scan-build make -f makefile.unix all

Current develop throws following warnings

/usr/bin/../libexec/ccc-analyzer -c -I./testprof/ -I./src/headers/ -DLTC_SOURCE -O2  -o src/ciphers/anubis.o   -c -o src/ciphers/anubis.o src/ciphers/anubis.c
src/ciphers/anubis.c:1001:27: warning: The left operand of '^' is a garbage value
      kappa[0] = inter[0] ^ rc[r];
                 ~~~~~~~~ ^
1 warning generated.

/usr/bin/../libexec/ccc-analyzer -c -I./testprof/ -I./src/headers/ -DLTC_SOURCE -O2  -o src/encauth/ccm/ccm_memory.o   -c -o src/encauth/ccm/ccm_memory.o src/encauth/ccm/ccm_memory.c
src/encauth/ccm/ccm_memory.c:148:17: warning: Call to 'malloc' has an allocation size of 0 bytes
      pt_work = XMALLOC(ptlen);
                ^~~~~~~~~~~~~~
./src/headers/tomcrypt_custom.h:6:18: note: expanded from macro 'XMALLOC'
#define XMALLOC  malloc
                 ^
1 warning generated.

/usr/bin/../libexec/ccc-analyzer -c -I./testprof/ -I./src/headers/ -DLTC_SOURCE -O2  -o src/pk/asn1/der/utctime/der_decode_utctime.o   -c -o src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_decode_utctime.c
src/pk/asn1/der/utctime/der_decode_utctime.c:88:5: warning: Function call argument is an uninitialized value
    DECODE_V(out->YY, 100);
    ^~~~~~~~~~~~~~~~~~~~~~
src/pk/asn1/der/utctime/der_decode_utctime.c:38:9: note: expanded from macro 'DECODE_V'
   y  = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \
        ^~~~~~~~~~~~~~~~~~~
src/pk/asn1/der/utctime/der_decode_utctime.c:88:5: warning: Function call argument is an uninitialized value
    DECODE_V(out->YY, 100);
    ^~~~~~~~~~~~~~~~~~~~~~
src/pk/asn1/der/utctime/der_decode_utctime.c:38:34: note: expanded from macro 'DECODE_V'
   y  = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \
                                 ^~~~~~~~~~~~~~~~~~~~~
src/pk/asn1/der/utctime/der_decode_utctime.c:89:5: warning: Function call argument is an uninitialized value
    DECODE_V(out->MM, 13);
    ^~~~~~~~~~~~~~~~~~~~~
src/pk/asn1/der/utctime/der_decode_utctime.c:38:9: note: expanded from macro 'DECODE_V'
   y  = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \
        ^~~~~~~~~~~~~~~~~~~
src/pk/asn1/der/utctime/der_decode_utctime.c:89:5: warning: Function call argument is an uninitialized value
    DECODE_V(out->MM, 13);
    ^~~~~~~~~~~~~~~~~~~~~
src/pk/asn1/der/utctime/der_decode_utctime.c:38:34: note: expanded from macro 'DECODE_V'
   y  = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \
                                 ^~~~~~~~~~~~~~~~~~~~~
4 warnings generated.
lulz @ the conversion from issue to PR ------- ... it changes the author of the initial comment... @karel-m wrote all this... `------------------` Although I am not sure how to do it I believe that it might be possible to utilize clang static analyzer in our automated travis builds. Manually you can start it like: ``` scan-build make -f makefile.unix all ``` Current develop throws following warnings ``` /usr/bin/../libexec/ccc-analyzer -c -I./testprof/ -I./src/headers/ -DLTC_SOURCE -O2 -o src/ciphers/anubis.o -c -o src/ciphers/anubis.o src/ciphers/anubis.c src/ciphers/anubis.c:1001:27: warning: The left operand of '^' is a garbage value kappa[0] = inter[0] ^ rc[r]; ~~~~~~~~ ^ 1 warning generated. /usr/bin/../libexec/ccc-analyzer -c -I./testprof/ -I./src/headers/ -DLTC_SOURCE -O2 -o src/encauth/ccm/ccm_memory.o -c -o src/encauth/ccm/ccm_memory.o src/encauth/ccm/ccm_memory.c src/encauth/ccm/ccm_memory.c:148:17: warning: Call to 'malloc' has an allocation size of 0 bytes pt_work = XMALLOC(ptlen); ^~~~~~~~~~~~~~ ./src/headers/tomcrypt_custom.h:6:18: note: expanded from macro 'XMALLOC' #define XMALLOC malloc ^ 1 warning generated. /usr/bin/../libexec/ccc-analyzer -c -I./testprof/ -I./src/headers/ -DLTC_SOURCE -O2 -o src/pk/asn1/der/utctime/der_decode_utctime.o -c -o src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_decode_utctime.c src/pk/asn1/der/utctime/der_decode_utctime.c:88:5: warning: Function call argument is an uninitialized value DECODE_V(out->YY, 100); ^~~~~~~~~~~~~~~~~~~~~~ src/pk/asn1/der/utctime/der_decode_utctime.c:38:9: note: expanded from macro 'DECODE_V' y = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \ ^~~~~~~~~~~~~~~~~~~ src/pk/asn1/der/utctime/der_decode_utctime.c:88:5: warning: Function call argument is an uninitialized value DECODE_V(out->YY, 100); ^~~~~~~~~~~~~~~~~~~~~~ src/pk/asn1/der/utctime/der_decode_utctime.c:38:34: note: expanded from macro 'DECODE_V' y = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \ ^~~~~~~~~~~~~~~~~~~~~ src/pk/asn1/der/utctime/der_decode_utctime.c:89:5: warning: Function call argument is an uninitialized value DECODE_V(out->MM, 13); ^~~~~~~~~~~~~~~~~~~~~ src/pk/asn1/der/utctime/der_decode_utctime.c:38:9: note: expanded from macro 'DECODE_V' y = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \ ^~~~~~~~~~~~~~~~~~~ src/pk/asn1/der/utctime/der_decode_utctime.c:89:5: warning: Function call argument is an uninitialized value DECODE_V(out->MM, 13); ^~~~~~~~~~~~~~~~~~~~~ src/pk/asn1/der/utctime/der_decode_utctime.c:38:34: note: expanded from macro 'DECODE_V' y = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \ ^~~~~~~~~~~~~~~~~~~~~ 4 warnings generated. ```
karel-m commented 2017-05-11 13:12:26 -05:00 (Migrated from github.com)

Another warnings in tests

rsa_test.c:533:6: warning: Value stored to 'cnt' is never read
     cnt = rsa_get_size(&key);
     ^     ~~~~~~~~~~~~~~~~~~

x86_prof.c:1489:7: warning: Potential leak of memory pointed to by 'buf'
      fprintf(stderr, "Warning the MAC tests requires AES and SHA1 to operate... so sorry\n");
      ^~~~~~~
Another warnings in tests ``` rsa_test.c:533:6: warning: Value stored to 'cnt' is never read cnt = rsa_get_size(&key); ^ ~~~~~~~~~~~~~~~~~~ x86_prof.c:1489:7: warning: Potential leak of memory pointed to by 'buf' fprintf(stderr, "Warning the MAC tests requires AES and SHA1 to operate... so sorry\n"); ^~~~~~~ ```
karel-m commented 2017-05-11 13:23:13 -05:00 (Migrated from github.com)

And in demos

   * /usr/bin/../libexec/ccc-analyzer demos/tv_gen.o
demos/tv_gen.c:738:29: warning: Division by zero
             key[z] = tag[z % len];
                          ~~^~~~~

   * /usr/bin/../libexec/ccc-analyzer demos/hashsum.o
In file included from ./src/headers/tomcrypt.h:9:0,
                 from demos/hashsum.c:10:
demos/hashsum.c: In function ‘check_file’:
demos/hashsum.c:107:16: error: array subscript has type ‘char’ [-Werror=char-subscripts]
             if(iscntrl(space[n])) {
                ^
And in demos ``` * /usr/bin/../libexec/ccc-analyzer demos/tv_gen.o demos/tv_gen.c:738:29: warning: Division by zero key[z] = tag[z % len]; ~~^~~~~ * /usr/bin/../libexec/ccc-analyzer demos/hashsum.o In file included from ./src/headers/tomcrypt.h:9:0, from demos/hashsum.c:10: demos/hashsum.c: In function ‘check_file’: demos/hashsum.c:107:16: error: array subscript has type ‘char’ [-Werror=char-subscripts] if(iscntrl(space[n])) { ^ ```
karel-m commented 2017-05-11 15:58:16 -05:00 (Migrated from github.com)

Warnings fixed and fixes merged to develop but I am leaving this issue open as we might want to try to add scan-build make .. to travis. IMO it would be better to merge improve/makefiles first.

Warnings fixed and fixes merged to develop but I am leaving this issue open as we might want to try to add `scan-build make ..` to travis. IMO it would be better to merge `improve/makefiles` first.
karel-m (Migrated from github.com) reviewed 2017-06-14 02:10:20 -05:00
karel-m (Migrated from github.com) left a comment

👍 please merge

👍 please merge
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libtom/libtomcrypt!217
No description provided.