{"record":{"id":"3323f97bebf725e5","repo":"NationalSecurityAgency/ghidra","slug":"invalid-integer-value-specified-for","errorCode":null,"errorMessage":"Invalid integer value specified for {}","messagePattern":"Invalid integer value specified for (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java","lineNumber":375,"sourceCode":"\t\t\tthrow new IllegalArgumentException(\"Missing required parameter: \" + name);\n\t\t}\n\t\tString p = params[index];\n\t\tif (p.startsWith(\"--\")) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\"Missing required parameter (\" + name + \") before specified option: \" + p);\n\t\t}\n\t}\n\n\tprivate int parsePositiveIntegerOption(String option, String optionValue) {\n\t\ttry {\n\t\t\tint value = Integer.valueOf(optionValue);\n\t\t\tif (value < 0) {\n\t\t\t\tthrow new IllegalArgumentException(\"Negative value not permitted for \" + option);\n\t\t\t}\n\t\t\treturn value;\n\t\t}\n\t\tcatch (NumberFormatException e) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid integer value specified for \" + option);\n\t\t}\n\t}\n\n\t/**\n\t * Verify that the given file is a PEM certificate\n\t * @param testFile the file to test\n\t * @return true if testFile looks like a PEM certificate\n\t * @throws IOException if there is a problem reading the given file\n\t */\n\tprivate static boolean verifyPEMFormat(File testFile) throws IOException {\n\t\tBufferedReader reader = new BufferedReader(new FileReader(testFile));\n\t\ttry {\n\t\t\t// All we currently do is search for the certificate header in the first 200 lines\n\t\t\tfor (int i = 0; i < 200; ++i) {\n\t\t\t\tString line = reader.readLine();\n\t\t\t\tif (line == null) {\n\t\t\t\t\tbreak;\n\t\t\t\t}","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java#L357-L393","documentation":"Thrown by parsePositiveIntegerOption when Integer.valueOf raises NumberFormatException because the option value is not a parseable integer. The catch block wraps it in this IllegalArgumentException.","triggerScenarios":"Passing a non-numeric or non-integer string such as `--port abc`, `--port 5432.0`, or `--port \" 5432\"` (line 375).","commonSituations":"Non-numeric config values, trailing whitespace or units (e.g. '5432 '), float strings, or locale-specific formatting.","solutions":["Provide a plain decimal integer string with no extra characters.","Strip whitespace/units from the value before passing.","Validate the value is numeric in the calling script before invoking the tool."],"exampleFix":"// before\nbsim control configure host --port abc\n// after\nbsim control configure host --port 5432","handlingStrategy":"validation","validationCode":"// Ensure the value is a clean integer string before launch.\nString trimmed = portValue == null ? \"\" : portValue.trim();\nif (!trimmed.matches(\"\\\\d+\")) {\n    System.err.println(\"Invalid integer for port: \" + portValue);\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    launchable.parsePositiveIntegerOption(option, value);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Invalid integer value\")) {\n        System.err.println(option + \" needs a plain integer, got: \" + value);\n    }\n    throw e;\n}","preventionTips":["Pre-validate integer strings with a numeric regex before invoking.","Trim whitespace and strip units from values in scripts.","Avoid locale-specific number formatting in CLI arguments."],"tags":["cli","argument-validation","bsim"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}