Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1694: Additional fix. Capture the first left-most x-forwarded-… #1704

Merged
merged 3 commits into from
Dec 23, 2024

Conversation

ganeshmurthy
Copy link
Contributor

…for header value

// The first X-Forwarded-For header is comma separated list, we will obtain the leftmost (the first) value (2001:db8:85a3:8d3:1319:8a2e:370:7348) in the list

// const uint8_t *value passed into this function is guaranteed to be NULL-terminated
char value_copy[valuelen+1];
Copy link
Contributor

@kgiusti kgiusti Dec 23, 2024

Choose a reason for hiding this comment

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

Is there a limit to valuelen? Can it be large enough to overflow the stack?

I mean, if you only want to capture the first address then you only need a buffer large enough to hold the longest address plus the header. IIRC ipv6 is like 45 chars max, so hardcoding a array size of 128 would be more than enough I would think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so hardcoding a array size of 128 would be more than enough I would think.

Agreed. I made the change. Thanks @kgiusti


// const uint8_t *value passed into this function is guaranteed to be NULL-terminated
char value_copy[128];
strncpy(value_copy, (const char *)value, 128);

Check warning

Code scanning / GNU C11

'strncpy' specified bound 128 equals destination size Warning

'strncpy' specified bound 128 equals destination size
@ganeshmurthy ganeshmurthy merged commit e94ec71 into skupperproject:main Dec 23, 2024
41 checks passed
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