Skip to content

WCCP: Fix offset calculation when parsing incoming packets - #2480

Closed
askolesnik wants to merge 1 commit into
squid-cache:masterfrom
askolesnik:fix/wccp2-sizeof-header-pointer
Closed

WCCP: Fix offset calculation when parsing incoming packets#2480
askolesnik wants to merge 1 commit into
squid-cache:masterfrom
askolesnik:fix/wccp2-sizeof-header-pointer

Conversation

@askolesnik

@askolesnik askolesnik commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Since 2021 commit 464223c, WCCPv2 packet parsing code was using
wrong offsets due to a CheckFieldDataLength() bug:

  • wccp2_item_header_t and wccp2_capability_info_header_t: The
    function returned a wrong offset on any 64-bit build, shifting
    dataStart and the returned field size by 4 bytes and desynchronizing
    the parse of subsequent WCCPv2 packet items;
  • wccp2_capability_element_t: The function happened to return a
    correct offset only on platforms with 8-byte pointers.

This change is a reference point for automated CONTRIBUTORS updates.

@squid-anubis squid-anubis added the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Aug 24, 2026
@squid-anubis

This comment was marked as resolved.

@rousskov rousskov left a comment

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.

@jert4803-droid, thank you for working on this bug fix.

Please adjust your PR branch to be based on the current official master branch. Without that adjustment, this PR modifies more than one thousand files, including (but not limited to) numerous unwanted Copyright line changes.

Please also add your entry to CONTRIBUTORS.

N.B. #970 contains the same code change, but that PR has been dormant since September 2023 (and no author activity since September 2022). I am not against merging this simple non-controversial fix first/now. This PR probably does not fix all Bug 5179 problems, but is a step forward.

@rousskov rousskov added the S-waiting-for-author author action is expected (and usually required) label Aug 24, 2026
CheckFieldDataLength() computed the field header size with
sizeof(header), where header is a pointer parameter, so it always
evaluated to the size of a pointer rather than the size of the
pointed-to FieldHeader struct; for the 4-byte header types
(wccp2_item_header_t, wccp2_capability_info_header_t) this yields a
wrong offset on any 64-bit build, shifting dataStart and the returned
field size by 4 bytes and desynchronizing the parse of subsequent WCCPv2
packet items, while for wccp2_capability_element_t it only happens to be
correct on platforms where pointers are 8 bytes; using sizeof(*header)
fixes the computation for every instantiation regardless of pointer
width.

Signed-off-by: Andrey Kolesnik <akolesnik@astralinux.ru>
@askolesnik
askolesnik force-pushed the fix/wccp2-sizeof-header-pointer branch from 9b80208 to c625171 Compare August 24, 2026 15:06
@askolesnik

Copy link
Copy Markdown
Contributor Author

@rousskov Thanks for the feedback !
Indeed, my commit wasn't based on the current version of the master branch.
I've now fixed everything and updated the PR.

@rousskov rousskov changed the title Fix sizeof(pointer) used instead of sizeof(*pointer) in CheckFieldDataLength WCCP: Fix offset calculation when parsing incoming packets Aug 24, 2026
@squid-anubis squid-anubis removed the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Aug 24, 2026

@rousskov rousskov left a comment

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.

Thank you for adjusting your PR. Please check whether update PR title/description match your changes. They will form a commit message when this PR is merged. Adjusted as needed.

@rousskov rousskov added the S-could-use-an-approval An approval may speed this PR merger (but is not required) label Aug 24, 2026
@askolesnik

askolesnik commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

@rousskov Yes, the title and description match the changes. Could you tell me if there are any requirements for the content of the title and description? Please provide recommendations or a link to information so I can take this into account for future changes. My original title and description didn't work.
Thanks !

@rousskov rousskov added M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels and removed S-waiting-for-author author action is expected (and usually required) labels Aug 25, 2026

@kinkie kinkie left a comment

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.

Thanks!

@kinkie kinkie added the backport-to-v7 maintainer has approved these changes for v7 backporting label Aug 26, 2026
squid-anubis pushed a commit that referenced this pull request Aug 26, 2026
Since 2021 commit 464223c, WCCPv2 packet parsing code was using
wrong offsets due to a `CheckFieldDataLength()` bug:

* `wccp2_item_header_t` and `wccp2_capability_info_header_t`: The
  function returned a wrong offset on any 64-bit build, shifting
  dataStart and the returned field size by 4 bytes and desynchronizing
  the parse of subsequent WCCPv2 packet items;
* `wccp2_capability_element_t`: The function happened to return a
  correct offset only on platforms with 8-byte pointers.

This change is a reference point for automated CONTRIBUTORS updates.
@squid-anubis squid-anubis added the M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels label Aug 26, 2026
@squid-anubis squid-anubis added M-merged https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels labels Aug 26, 2026
@squidadm squidadm removed the backport-to-v7 maintainer has approved these changes for v7 backporting label Aug 26, 2026
@squidadm

Copy link
Copy Markdown
Collaborator

queued for backport to v7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

M-merged https://github.com/measurement-factory/anubis#pull-request-labels S-could-use-an-approval An approval may speed this PR merger (but is not required)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants