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-09-30 01:48:58 +01:00 committed by Tim Edwards
parent 4ca98dc31b
commit 96c7e283c0
1 changed files with 5 additions and 1 deletions

View File

@ -978,8 +978,12 @@ gcrShowMap(ch)
while (1) while (1)
{ {
TxPrintf("Field selector (0 terminates): "); 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("Bad input. Legal responses are\n");
TxPrintf(" GCRBLKM 1\n"); TxPrintf(" GCRBLKM 1\n");
TxPrintf(" GCRBLKP 2\n"); TxPrintf(" GCRBLKP 2\n");