Skip to content

Conversation

@rob-cobbins
Copy link

PROBLEM:
When service-probes defines multiple CPE entries of the same part type (e.g., two application CPEs like Apache and PHP), only the last one was stored as the CPE loop overwrote the single buffer for each type.

ROOT CAUSE:

  • MatchDetails structure used single const char* for cpe_a/h/o
  • ServiceNFO class used single char arrays for cpe_*_matched
  • CPE processing loop reused the same buffer, overwriting previous values
  • Only the last CPE of each type was retained

SOLUTION:

  • Changed MatchDetails to use std::vector<const char *> for cpe_a/h/o
  • Changed ServiceNFO to use std::vector<char > for cpe__matched
  • Updated CPE processing loop to allocate new buffers for each CPE
  • Added proper memory management (free in destructors and SSL reset)
  • Updated all copying/transfer logic to iterate vectors

VERIFICATION:
Tested against servers with Apache + PHP and confirmed XML output now shows multiple tags as expected:
cpe:/a:apache:http_server:2.4.34
cpe:/a:php:php:7.3.20

FILES MODIFIED:

  • service_scan.h: MatchDetails structure
  • service_scan.cc: ServiceNFO class, getVersionStr, testMatch, processMatch, processResults, and cleanup code

PROBLEM:
When service-probes defines multiple CPE entries of the same part type
(e.g., two application CPEs like Apache and PHP), only the last one was
stored as the CPE loop overwrote the single buffer for each type.

ROOT CAUSE:
- MatchDetails structure used single const char* for cpe_a/h/o
- ServiceNFO class used single char arrays for cpe_*_matched
- CPE processing loop reused the same buffer, overwriting previous values
- Only the last CPE of each type was retained

SOLUTION:
- Changed MatchDetails to use std::vector<const char *> for cpe_a/h/o
- Changed ServiceNFO to use std::vector<char *> for cpe_*_matched
- Updated CPE processing loop to allocate new buffers for each CPE
- Added proper memory management (free in destructors and SSL reset)
- Updated all copying/transfer logic to iterate vectors

VERIFICATION:
Tested against servers with Apache + PHP and confirmed XML output now
shows multiple <cpe> tags as expected:
  <cpe>cpe:/a:apache:http_server:2.4.34</cpe>
  <cpe>cpe:/a:php:php:7.3.20</cpe>

FILES MODIFIED:
- service_scan.h: MatchDetails structure
- service_scan.cc: ServiceNFO class, getVersionStr, testMatch,
  processMatch, processResults, and cleanup code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants