From 64d94ae5881d2221bf3514e0c43771d6fbc2a386 Mon Sep 17 00:00:00 2001 From: Darryl Miles Date: Mon, 30 Sep 2024 01:46:52 +0100 Subject: [PATCH] router/rtrCmd.c: Incorrect return-value check for a 'scanf'-like function Fix code scanning alert no. 156: Incorrect return-value check for a 'scanf'-like function (#6) * Create codeql.yml * Fix code scanning alert no. 156: 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> --- router/rtrCmd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/router/rtrCmd.c b/router/rtrCmd.c index 55e94271..d33abea8 100644 --- a/router/rtrCmd.c +++ b/router/rtrCmd.c @@ -640,7 +640,7 @@ CmdRoute(w, cmd) { if(cmd->tx_argc!=3) goto wrongNumArgs; - if(!sscanf(cmd->tx_argv[2], "%d", &RtrViaLimit)) + if(sscanf(cmd->tx_argv[2], "%d", &RtrViaLimit) != 1) TxError("Bad value for via limit\n"); } TxPrintf("Via limit is %d\n", RtrViaLimit); @@ -650,7 +650,7 @@ CmdRoute(w, cmd) { if(cmd->tx_argc!=3) goto wrongNumArgs; - if(!sscanf(cmd->tx_argv[2], "%f", &RtrEndConst)) + if(sscanf(cmd->tx_argv[2], "%f", &RtrEndConst) != 1) TxError("Bad value for channel end distance\n"); } TxPrintf("Channel end constant is %f\n", RtrEndConst); @@ -660,7 +660,7 @@ CmdRoute(w, cmd) { if(cmd->tx_argc!=3) goto wrongNumArgs; - if(!sscanf(cmd->tx_argv[2], "%d", &GCRMinJog)) + if(sscanf(cmd->tx_argv[2], "%d", &GCRMinJog) != 1) TxError("Bad value for minimum jog length\n"); } TxPrintf("Minimum jog length is %d\n", GCRMinJog); @@ -670,7 +670,7 @@ CmdRoute(w, cmd) { if(cmd->tx_argc!=3) goto wrongNumArgs; - if(!sscanf(cmd->tx_argv[2], "%f", &GCRObstDist)) + if(sscanf(cmd->tx_argv[2], "%f", &GCRObstDist) != 1) TxError("Bad value for obstacle constant\n"); } TxPrintf("Obstacle constant is %f\n", GCRObstDist); @@ -680,7 +680,7 @@ CmdRoute(w, cmd) { if(cmd->tx_argc!=3) goto wrongNumArgs; - if(!sscanf(cmd->tx_argv[2], "%d", &GCRSteadyNet)) + if(sscanf(cmd->tx_argv[2], "%d", &GCRSteadyNet) != 1) TxError("Bad value for steady net constant\n"); } TxPrintf("Steady net constant is %d\n", GCRSteadyNet);