Skip to content

C++: Use new getConvSpecString instead of getConvSpecOffset and substring#21702

Merged
jketema merged 2 commits intogithub:mainfrom
jketema:conv-string
Apr 14, 2026
Merged

C++: Use new getConvSpecString instead of getConvSpecOffset and substring#21702
jketema merged 2 commits intogithub:mainfrom
jketema:conv-string

Conversation

@jketema
Copy link
Copy Markdown
Contributor

@jketema jketema commented Apr 13, 2026

Should address glibc timeout in BMN DCA.

Three DCA experiments in order of occurrence (of open issues):

  • BMN using the last known working nightly SHA-pair as a base: has a lot of changes, but shows that glibc is working again,
  • BMN with just the change: glibc obviously fails, these experiments seem quite noisy, but I see no reason for concern that this PR regresses anything
  • Traced: looks good, I do see that I did not quite manage to stabilize nmap; the tinyxml2 analysis time difference we've only seen in nightlies, so is not an immediate reason for concern.

Please ignore the Custom Sources DCA experiment(s), and other closed experiment issues.

@github-actions github-actions bot added the C++ label Apr 13, 2026
@jketema jketema changed the title C++: Use getConvSpecString instead of getConvSpecOffset and substring C++: Use new getConvSpecString instead of getConvSpecOffset and substring Apr 13, 2026
* Gets the nth conversion specifier string.
*/
private string getConvSpecString(int n) {
n >= 0 and result = "%" + this.getFormat().splitAt("%", n + 1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, it's quite clean for what it accomplishes. 👍

@jketema jketema marked this pull request as ready for review April 14, 2026 06:04
@jketema jketema requested a review from a team as a code owner April 14, 2026 06:04
Copilot AI review requested due to automatic review settings April 14, 2026 06:04
@jketema jketema added the no-change-note-required This PR does not need a change note label Apr 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the C++ printf/scanf format-string parsing helpers to extract conversion-specifier substrings via a new getConvSpecString helper, avoiding offset+substring usage in the parsing predicates (intended to address a glibc timeout seen in BMN DCA).

Changes:

  • Add getConvSpecString(int n) helper to both Scanf.qll and Printf.qll.
  • Update conversion-spec parsing to operate on the new extracted substring (convSpec) rather than substring(offset, ...).
Show a summary per file
File Description
cpp/ql/lib/semmle/code/cpp/commons/Scanf.qll Introduces getConvSpecString and uses it in parseConvSpec to avoid offset+substring extraction.
cpp/ql/lib/semmle/code/cpp/commons/Printf.qll Introduces getConvSpecString and uses it in parseConvSpec and getConvSpec to avoid offset+substring extraction.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment on lines +197 to +202
/**
* Gets the nth conversion specifier string.
*/
private string getConvSpecString(int n) {
n >= 0 and result = "%" + this.getFormat().splitAt("%", n + 1)
}
Comment on lines +462 to +467
/**
* Gets the nth conversion specifier string.
*/
private string getConvSpecString(int n) {
n >= 0 and result = "%" + this.getFormat().splitAt("%", n + 1)
}
@jketema jketema merged commit 0724c22 into github:main Apr 14, 2026
23 of 24 checks passed
@jketema jketema deleted the conv-string branch April 14, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C++ no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants