From e66e3b32ad2806b11e38d8a20b1c2cfe7bdc058f Mon Sep 17 00:00:00 2001 From: Darryl Miles Date: Mon, 30 Sep 2024 01:49:18 +0100 Subject: [PATCH] extract/ExtBasic.c: Incorrect return-value check for a 'scanf'-like function Fix code scanning alert no. 149: Incorrect return-value check for a 'scanf'-like function (#10) * Create codeql.yml * Fix code scanning alert no. 149: 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> --- extract/ExtBasic.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/extract/ExtBasic.c b/extract/ExtBasic.c index 0f45ce3e..7ca31c2c 100644 --- a/extract/ExtBasic.c +++ b/extract/ExtBasic.c @@ -427,14 +427,14 @@ extBasic(def, outFile) case DEV_FET: /* Read area */ token = strtok(NULL, " "); - if ((token == NULL) || !sscanf(token, "%d", &w)) + if ((token == NULL) || (sscanf(token, "%d", &w) != 1)) propfound = FALSE; else w *= ExtCurStyle->exts_unitsPerLambda * ExtCurStyle->exts_unitsPerLambda; /* Read perimeter */ token = strtok(NULL, " "); - if ((token == NULL) || !sscanf(token, "%d", &l)) + if ((token == NULL) || (sscanf(token, "%d", &l) != 1)) propfound = FALSE; else l *= ExtCurStyle->exts_unitsPerLambda; @@ -444,13 +444,13 @@ extBasic(def, outFile) case DEV_BJT: /* Read width */ token = strtok(NULL, " "); - if ((token == NULL) || !sscanf(token, "%d", &w)) + if ((token == NULL) || (sscanf(token, "%d", &w) != 1)) propfound = FALSE; else w *= ExtCurStyle->exts_unitsPerLambda; /* Read length */ token = strtok(NULL, " "); - if ((token == NULL) || !sscanf(token, "%d", &l)) + if ((token == NULL) || (sscanf(token, "%d", &l) != 1)) propfound = FALSE; else l *= ExtCurStyle->exts_unitsPerLambda; @@ -460,13 +460,13 @@ extBasic(def, outFile) { /* Read width */ token = strtok(NULL, " "); - if ((token == NULL) || !sscanf(token, "%d", &w)) + if ((token == NULL) || (sscanf(token, "%d", &w) != 1)) propfound = FALSE; else w *= ExtCurStyle->exts_unitsPerLambda; /* Read length */ token = strtok(NULL, " "); - if ((token == NULL) || !sscanf(token, "%d", &l)) + if ((token == NULL) || (sscanf(token, "%d", &l) != 1)) propfound = FALSE; else l *= ExtCurStyle->exts_unitsPerLambda; @@ -479,14 +479,14 @@ extBasic(def, outFile) { /* Read area */ token = strtok(NULL, " "); - if ((token == NULL) || !sscanf(token, "%d", &w)) + if ((token == NULL) || (sscanf(token, "%d", &w) != 1)) propfound = FALSE; else w *= ExtCurStyle->exts_unitsPerLambda * ExtCurStyle->exts_unitsPerLambda; /* Read perimeter */ token = strtok(NULL, " "); - if ((token == NULL) || !sscanf(token, "%d", &l)) + if ((token == NULL) || (sscanf(token, "%d", &l) != 1)) propfound = FALSE; else l *= ExtCurStyle->exts_unitsPerLambda;