units-2.21-4.el9

List of Findings

Error: COMPILER_WARNING (CWE-563): [#def1]
units-2.21/units.c: scope_hint: In function 'openfile'
units-2.21/units.c:396:7: warning[-Wunused-variable]: unused variable 'ret'
#  396 |   int ret;
#      |       ^~~
#  394|   {
#  395|     FILE *fileptr;
#  396|->   int ret;
#  397|   
#  398|     struct stat statbuf;

Error: CPPCHECK_WARNING (CWE-476): [#def2]
units-2.21/units.c:621: error[nullPointer]: Null pointer dereference
#  619|     len = strlen(str)+1;
#  620|     widestr = mymalloc(sizeof(wchar_t)*len, "(strwidth)");
#  621|->   len = mbsrtowcs(widestr, &str, len, NULL);
#  622|   
#  623|     if (len==-1){

Error: COMPILER_WARNING (CWE-563): [#def3]
units-2.21/units.c: scope_hint: In function 'readunits'
units-2.21/units.c:804:41: warning[-Wunused-value]: value computed is not used
#  804 | #define readerror (goterr=1) && errfile && fprintf
#      |                                         ^~
units-2.21/units.c:1645:9: note: in expansion of macro 'readerror'
# 1645 |         readerror(errfile, "%s: %s on line %d of '%s'\n",
#      |         ^~~~~~~~~
#  802|   
#  803|   
#  804|-> #define readerror (goterr=1) && errfile && fprintf
#  805|   
#  806|   #define VAGUE_ERR "%s: error in units file '%s' line %d\n", \

Error: CPPCHECK_WARNING (CWE-401): [#def4]
units-2.21/units.c:1408: error[memleakOnRealloc]: Common realloc mistake: 'tab' nulled but not freed upon failure
# 1406|       if (tabpt>=tablealloc){
# 1407|         tablealloc+=20;
# 1408|->       tab = (struct pair *)realloc(tab,sizeof(struct pair)*tablealloc);
# 1409|         if (!tab){
# 1410|           if (errfile) fprintf(errfile, "%s: memory allocation error (newtable)\n",

Error: CPPCHECK_WARNING (CWE-476): [#def5]
units-2.21/units.c:2376: error[ctunullpointer]: Null pointer dereference: first
# 2374|   {
# 2375|      return
# 2376|->       compareproducts(first->numerator, second->numerator, isdimless) ||
# 2377|         compareproducts(first->denominator, second->denominator, isdimless);
# 2378|   }

Error: COMPILER_WARNING (CWE-457): [#def6]
units-2.21/units.c: scope_hint: In function 'showfunction'
units-2.21/units.c:2848:21: warning[-Wmaybe-uninitialized]: 'not_dimensionless' may be used uninitialized in this function
# 2848 |     if (func->dimen && (not_dimensionless || unit.factor != 1)){
#      |         ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 2846|         logprintf(num_format.format, *func->domain_min);
# 2847|       }
# 2848|->     if (func->dimen && (not_dimensionless || unit.factor != 1)){
# 2849|         if (isdecimal(*func->dimen))
# 2850|           logputs(" *");

Error: COMPILER_WARNING (CWE-563): [#def7]
units-2.21/units.c: scope_hint: In function 'checkcwd'
units-2.21/units.c:4131:9: warning[-Wunused-variable]: unused variable 'p'
# 4131 |   char *p;
#      |         ^
# 4129|   {
# 4130|     FILE *fp;
# 4131|->   char *p;
# 4132|   
# 4133|     fp = openfile(file, "r");

Error: CPPCHECK_WARNING (CWE-672): [#def8]
units-2.21/units.c:4536: error[deallocret]: Returning/dereferencing 'file' after it is deallocated / released
# 4534|     else {
# 4535|       fclose(testfile);
# 4536|->     return file;
# 4537|     }
# 4538|   }

Error: COMPILER_WARNING (CWE-563): [#def9]
units-2.21/units.c: scope_hint: In function 'printversion'
units-2.21/units.c:4749:9: warning[-Wunused-variable]: unused variable 'fp'
# 4749 |   FILE *fp, *histfile;
#      |         ^~
# 4747|     char *m_unitsfile;         /* personal units data file from HOME_UNITS_ENV */
# 4748|     char *p_unitsfile;         /* personal units data file */
# 4749|->   FILE *fp, *histfile;
# 4750|   #ifdef _WIN32
# 4751|     char *localemap;

Scan Properties

analyzer-version-clippy1.83.0
analyzer-version-cppcheck2.9
analyzer-version-gcc11.5.0
analyzer-version-gcc-analyzer11.5.0
analyzer-version-shellcheck0.8.0
analyzer-version-unicontrol0.0.2
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-159.us-west-2.compute.internal
mock-configcentos-stream+epel-9-x86_64
project-nameunits-2.21-4.el9
store-results-to/tmp/tmpj3we0q0t/units-2.21-4.el9.tar.xz
time-created2025-01-30 04:59:34
time-finished2025-01-30 05:02:02
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'centos-stream+epel-9-x86_64' '-t' 'cppcheck,clippy,shellcheck,gcc,unicontrol' '-o' '/tmp/tmpj3we0q0t/units-2.21-4.el9.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '/tmp/tmpj3we0q0t/units-2.21-4.el9.src.rpm'
tool-versioncsmock-3.8.0-1.el9