gcr/gcrDebug.c: Incorrect return-value check for a 'scanf'-like function

Fix code scanning alert no. 137: Incorrect return-value check for a 'scanf'-like function (#9)

* Create codeql.yml

* Fix code scanning alert no. 137: Incorrect return-value check for a 'scanf'-like function

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
Darryl Miles
2024-10-01 12:36:12 -04:00
committed by Tim Edwards
co-authored by Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
parent 4ca98dc31b
commit 96c7e283c0
+5 -1
View File
@@ -978,8 +978,12 @@ gcrShowMap(ch)
while (1)
{
TxPrintf("Field selector (0 terminates): ");
if(!scanf("%d", &field)) /*typed something funny*/
if(scanf("%d", &field) != 1) /*typed something funny or EOF*/
{
if (feof(stdin)) {
TxPrintf("End of input detected. Terminating.\n");
return;
}
TxPrintf("Bad input. Legal responses are\n");
TxPrintf(" GCRBLKM 1\n");
TxPrintf(" GCRBLKP 2\n");