Commit Graph

2057 Commits

Author SHA1 Message Date
Darryl L. Miles 1ca23ca0a2 fix: Accessing uninitialized variable
Trigger condition maybe that no labels exist in the project, so the
loop never iterates.
2024-10-01 12:43:27 -04:00
Darryl L. Miles 8e0f34c6f1 debug/hist.c Access .. results in a dereference of a null
Maybe this is only a bug if a call to HistAdd() is made before HistCreate().

SonarCloud
debug/hist.c:147 Access to field 'hi_cum' results in a dereference of a null pointer (loaded from variable 'h')
https://sonarcloud.io/project/issues?open=AZJB17kdNGfDNup0RkzB&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 60fe6427da graphics/grX11su1.c: Dereference of null pointer
Looks like the code below requires w!=NULL to do anything useful.
So when w==NULL we don't continue processing X11 Event.

SonarCloud
graphics/grX11su1.c:895 Dereference of null pointer
https://sonarcloud.io/project/issues?open=AZJB163RNGfDNup0Ri4p&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 01f9f2246b graphics/grX11su1.c: Dereference of null pointer
Looks like the code below requires w!=NULL to do anything useful.
So when w==NULL we don't continue processing X11 Event.

SonarCloud
graphics/grX11su1.c:842 Dereference of null pointer
https://sonarcloud.io/project/issues?open=AZJB163RNGfDNup0Ri4o&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles cb31675174 utils/geometry.c: non-void function does not return a value in all control paths
Had to pick a value to return by default.  This is a probably should never happen ?

SonarCloud
utils/geometry.c:589 non-void function does not return a value in all control paths
https://sonarcloud.io/project/issues?open=AZJB16DGNGfDNup0Rg7u&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles bfd818fbd3 textio/txInput.c non-void function does not return a value
This function is related to libreadline rl_pre_input_hook callback
which is invoked as (not making use of any function return value):

readline.c:    (*rl_pre_input_hook) ();

The general prototype for this function is:

rltypedefs.h:typedef int rl_hook_func_t PARAMS((void));

So the resolution is to provide a known value as the return value, which
resolves the concern.

SonarCloud
textio/txInput.c:550 non-void function does not return a value
https://sonarcloud.io/project/issues?open=AZJB17NwNGfDNup0Rj5G&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles ab747a0f8c grouter/groutePin.c: multiple: non-void function does not return a value
Multiple reports exists in this file

Affected functions:
 GLInitPins() now returns void
 glPinArrayInit() now returns void
 GLLinkPins() now returns void
 glPinArrayLink() now returns void
 GLFixStemPins() now returns void
 glPinArrayFixStems() now returns void

SonarCloud
https://sonarcloud.io/project/issues?open=AZJB17L0NGfDNup0Rj0D&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 8b2efd5d7d gcr/gcrDebug.c Opened stream never closed. Potential resource leak
A false positive in practice, made clearer by using a 2nd variable
with attention drawing name.

SonarCloud
gcr/gcrDebug.c:429 Opened stream never closed. Potential resource leak
https://sonarcloud.io/project/issues?open=AZJB17OzNGfDNup0Rj-t&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 0cea17e801 utils/magic.h pointertype prefer use of 'long' instead of 'int'
It is usual for a pointer to require the largest width, while some
platforms might have an 'int' that is smaller than a pointer width.

This reverses the detection order to find.

Note since C99 there is <stdint.h> with type 'intmax_t' which
serves a similar purpose.

SonarCloud reports a concern with this on many lines where used.
"An integral type is too small to hold a pointer value."
https://sonarcloud.io/project/issues?open=AZJB17ZoNGfDNup0RkY_&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles a0aea2aa2e gcr/gcrDebug.c Add a field width specifier to this "%s" placeholder.
Unbounded local buffer used in fscanf() string extraction call.
Add width to specified to ensure truncation as 24 character instead
of buffer overflow.

SonarCloud https://sonarcloud.io/project/issues?open=AZJB17OzNGfDNup0Rj9x&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 29ee094074 graphics/grOGL1.c Dereference of null pointer
Looks like the code below requires mw!=NULL to do anything useful.
So when mw==NULL we don't continue processing X11 Event.

SonarCloud
graphics/grOGL1.c:563 Dereference of null pointer
https://sonarcloud.io/project/issues?open=AZJB16z6NGfDNup0Riss&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles be258c6557 graphics/grOGL1.c: non-void function does not return a value
Making oglSetProjection() return void, like toglSetProjection()

SonarCloud
graphics/grOGL1.c:408 non-void function does not return a value
https://sonarcloud.io/project/issues?open=AZJB16z6NGfDNup0Riro&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles ae0cdd9fea graphics/grClip.c Branch condition evaluates to a garbage value
This is technically a false positive as grClipPoints() will always
initializes a value to ok1 and ok2 when called.  The function is in
the same compile unit, so probably the compiler can see this as well
and potentially not perform the initiailization begin performed in
this commit.

But to quieten and remove this item from the analysis report
assigning an initialization value.

SonarCloud
graphics/grClip.c:451 Branch condition evaluates to a garbage value
https://sonarcloud.io/project/issues?open=AZJB160MNGfDNup0Rit4&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 10442b6534 graphics/cairo_orig/grTCairo5.c uninitialized local variable
Looks like old code.  Based on cairo_fill() action state this is initialized to
no-op by default.

SonarCloud
graphics/cairo_orig/grTCairo5.c:107 The left operand of '!=' is a garbage value
https://sonarcloud.io/project/issues?open=AZJB16wANGfDNup0RiiZ&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 5e00e3fe1b graphics/cairo_orig/grTCairo3.c uninitialized value
Looks like old code.  Looks like local variable 'j' could be removed.
Initialization lowers the severity of concern in this area.
The 'j' variable is now written but never read.

SonarCloud
graphics/cairo_orig/grTCairo3.c:492
The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage
https://sonarcloud.io/project/issues?open=AZJB16voNGfDNup0Rig_&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles a9b707460b garouter/gaChannel.c use of unintialized or incorrect variable
This resolution assumes that all records and values of ch->gcr_type are expected
to be one of the 3 cases in the switch.  The bug it on the first iteration it is
possible 'tot' and 'clear' is just not initializaed and on a subsequent iteration
it is possible it ot setup to the previous interation values.

SonarCloud
garouter/gaChannel.c:385:3rd function call argument is an uninitialized value
https://sonarcloud.io/project/issues?open=AZJB17fFNGfDNup0RkoE&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 543bd5a5b8 ext2sim/sim2simp.c ParseAttr does not return a value
SonarCloud
ext2sim/sim2simp.c:43 non-void function 'parseAttr' should return a value
https://sonarcloud.io/project/issues?open=AZJB17kzNGfDNup0RkzS&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 973c9a4d1a database/DBio.c read of variable before initialization
Due to FEOF condition and handling it is possible local variable 'c' is not
initialized before being read and compared.

SonarCloud retails
DBio.c:3049 The left operand of '==' is a garbage value
https://sonarcloud.io/project/issues?open=AZJB16rxNGfDNup0Ribf&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 48853b98a3 calma/CalmaRead.c missing initialization
An FEOF exit path exists in READRH() which causes the output
variable(s) to not be assigned a value, then the code makes
a decision (branch) based on uninitialized data.

SonarCloud detection
CalmaRead.c:359:The left operand of '!=' is a garbage value
https://sonarcloud.io/project/issues?open=AZJB17gSNGfDNup0Rkp5&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 290887912f ext2spice/ext2hier.c: Wrong type of arguments to formatting function
Applied the same fixes as other commits already merged into file.

Copilot Autofix: Error contact support...

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/38
        https://github.com/dlmiles/magic/security/code-scanning/39
        https://github.com/dlmiles/magic/security/code-scanning/41
2024-10-01 12:36:13 -04:00
Darryl L. Miles 62ebf49758 mzrouter/mzEstimate.c: (intmax_t) %lx Wrong type of arguments to formatting function
Copilot Autofix rejected: TxPrintf("\ntile %p\t\t  (x: %d to %d, y: %d to %d)\n",

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/102
2024-10-01 12:36:13 -04:00
Darryl L. Miles 7509802b3d mzrouter/mzDebug.c: (intmax_t) %lx Wrong type of arguments to formatting function
Copilot Autofix rejected: TxPrintf("tile %p  (x: %d to %d, y: %d to %d)\n"

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/101
2024-10-01 12:36:13 -04:00
Darryl Miles 2c8c60510b plot/plotRutils.c: Multiplication result converted to larger type
Fix code scanning alert no. 56: Multiplication result converted to larger type (#67)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 14a1b21fb6 extract/ExtHier.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 159: Wrong type of arguments to formatting function (#66)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl L. Miles 4dc708aea2 ext2spice/ext2spice.c: Multiplication result converted to larger type
Applying similat fix to others in the file, promote to double ASAP.

Copilot Autofix: Retry and if the problem persists contact support.

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/46
2024-10-01 12:36:13 -04:00
Darryl Miles 98b5f57ea0 ext2spice/ext2spice.c: Multiplication result converted to larger type
Fix code scanning alert no. 48: Multiplication result converted to larger type (#63)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 3becc0e03f ext2spice/ext2spice.c: Multiplication result converted to larger type
Fix code scanning alert no. 47: Multiplication result converted to larger type (#62)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles a6db54c0b7 ext2spice/ext2spice.c: Multiplication result converted to larger type
Fix code scanning alert no. 45: Multiplication result converted to larger type (#61)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 7e04089872 ext2spice/ext2spice.c: Multiplication result converted to larger type
Fix code scanning alert no. 44: Multiplication result converted to larger type (#60)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles cde5418e7d ext2spice/ext2spice.c: Multiplication result converted to larger type
Fix code scanning alert no. 43: Multiplication result converted to larger type (#59)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 9327388ae0 ext2spice/ext2hier.c: Multiplication result converted to larger type
Fix code scanning alert no. 42: Multiplication result converted to larger type (#65)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 147ca7a61f ext2spice/ext2hier.c: Multiplication result converted to larger type
Fix code scanning alert no. 40: Multiplication result converted to larger type (#64)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles fe39d889f0 plot/plotRutils.c: Multiplication result converted to larger type
Fix code scanning alert no. 54: Multiplication result converted to larger type (#56)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 86a6551f9b ext2spice/ext2hier.c: Multiplication result converted to larger type
Fix code scanning alert no. 37: Multiplication result converted to larger type (#58)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 82bec60ccf ext2spice/ext2hier.c: Multiplication result converted to larger type
Fix code scanning alert no. 36: Multiplication result converted to larger type (#57)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 691c27081f drc/DRCcif.c: Multiplication result converted to larger type
Fix code scanning alert no. 34: Multiplication result converted to larger type (#54)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 1fb82e7225 database/DBtiles.c: Multiplication result converted to larger type
Fix code scanning alert no. 30: Multiplication result converted to larger type (#55)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles d8b886aa1d debug/debugFlags.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 67: Wrong type of arguments to formatting function (#45)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 846f2b4cb1 debug/debugFlags.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 68: Wrong type of arguments to formatting function (#46)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 40f96faff8 plot/plotPNM.c: Multiplication result converted to larger type
Fix code scanning alert no. 55: Multiplication result converted to larger type (#47)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 5ffc74d915 lef/defWrite.c: Multiplication result converted to larger type
Fix code scanning alert no. 53: Multiplication result converted to larger type (#48)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 1a351efd56 extract/ExtBasic.c: Multiplication result converted to larger type
Fix code scanning alert no. 52: Multiplication result converted to larger type (#49)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 00086817a4 extract/ExtCouple.c: Multiplication result converted to larger type
Fix code scanning alert no. 51: Multiplication result converted to larger type (#50)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles d6cc790d48 extflat/EFvisit.c: Multiplication result converted to larger type
Fix code scanning alert no. 50: Multiplication result converted to larger type (#51)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 6cae64edc5 drc/DRCbasic.c: Multiplication result converted to larger type
Fix code scanning alert no. 35: Multiplication result converted to larger type (#53)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 5a8cdb68d0 ext2spice/ext2spice.c: Multiplication result converted to larger type
Fix code scanning alert no. 49: Multiplication result converted to larger type (#52)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles f809b2dfac graphics/grTk1.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 98: Wrong type of arguments to formatting function (#44)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 9096946a12 windows/windDebug.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 130: Wrong type of arguments to formatting function (#43)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 3848ec7b4e extract/ExtHier.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 71: Wrong type of arguments to formatting function (#37)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl L. Miles 2703f55449 extract/ExtTest.c: Too few arguments to formatting function
A bit of a guess based on context.

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/58
        https://github.com/dlmiles/magic/security/code-scanning/59
2024-10-01 12:36:13 -04:00