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

Mekhanik evgenii/fix bug with access already freed mem #760

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

EvgeniiMekhanik
Copy link
Contributor

No description provided.

@EvgeniiMekhanik EvgeniiMekhanik force-pushed the MekhanikEvgenii/fix-bug-with-access-already-freed-mem branch 7 times, most recently from 3f3abd4 to e7e74a2 Compare February 7, 2025 01:39
http_general/test_headers.py Outdated Show resolved Hide resolved
return

self.assertEqual(server.last_request.headers.get('trailer'), tr1 + " " + tr2)
if not self.__is_hbp(tr1):
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably you should add checks if trailer is hbp?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes fixed

self, name, method, tr1, tr1_val, tr2, tr2_val, expected_status_code
):
self.start_all_services()
self.disable_deproxy_auto_parser()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you disable the parser?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

tr1_val="keep-alive",
tr2="Keep-Alive",
tr2_val="timeout=5, max=100",
expected_status_code="200"
Copy link
Contributor

Choose a reason for hiding this comment

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

You should remove expected_status_code from test params. You always use 200.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 579 to 612
if not isinstance(client, DeproxyClientH2):
if method != "HEAD" and not self.__is_hbp(tr1):
self.assertEqual(
client.last_response.trailer.get(tr1),
tr1_val,
"Moved trailer header value mismatch the original one",
)
else:
self.assertFalse(client.last_response.trailer.get(tr1))
if method != "HEAD" and not self.__is_hbp(tr2):
self.assertEqual(
client.last_response.trailer.get(tr2),
tr2_val,
"Moved trailer header value mismatch the original one",
)
else:
self.assertFalse(client.last_response.trailer.get(tr2))
self.assertEqual(client.last_response.headers.get("Transfer-Encoding"), "chunked")
self.assertEqual(client.last_response.headers.get("Trailer"), tr1 + " " + tr2)
self.assertIsNone(client.last_response.headers.get(tr1))
self.assertIsNone(client.last_response.headers.get(tr2))
else:
if method != "HEAD" and not self.__is_hbp(tr1):
self.assertEqual(
client.last_response.headers.get(tr1),
tr1_val,
"Moved trailer header value mismatch the original one",
)
if method != "HEAD" and not self.__is_hbp(tr2):
self.assertEqual(
client.last_response.headers.get(tr2),
tr2_val,
"Moved trailer header value mismatch the original one",
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add checks like test params. For example:

    def assert_HEAD_http2_request(self, response):
        self.assertIsNone(response.trailer.get(tr1))
        self.assertIsNone(response.trailer.get(tr2))

    @marks.Parameterize.expand(
        [
            marks.Param(
                name="no_hbp_GET",
                method="GET",
                tr1="X-Token1",
                tr1_val="value1",
                tr2="X-Token2",
                tr2_val="value2",
                assert_func=assert_HEAD_http2_request,
            ),
    ...
    ]
    def test_trailers_in_response(
        self, name, method, tr1, tr1_val, tr2, tr2_val, assert_func
        ...
        assert_func(self, client.last_response)
    ):

Also you can move this checks to DeproxyAutoParser, or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@EvgeniiMekhanik EvgeniiMekhanik force-pushed the MekhanikEvgenii/fix-bug-with-access-already-freed-mem branch from e7e74a2 to 9fa396a Compare February 11, 2025 01:40
Now Tempesta blocks all bodyless methods requests
if body is present (in case of chunked body also).
So change method to POST in tests.
Linux reset ipv6 address if we set mtu less then 1500, so
we should restore it ater test finished.
@EvgeniiMekhanik EvgeniiMekhanik marked this pull request as draft February 11, 2025 20:31
@EvgeniiMekhanik EvgeniiMekhanik force-pushed the MekhanikEvgenii/fix-bug-with-access-already-freed-mem branch 2 times, most recently from 678f1f1 to ba962c8 Compare February 11, 2025 21:29
@EvgeniiMekhanik EvgeniiMekhanik force-pushed the MekhanikEvgenii/fix-bug-with-access-already-freed-mem branch from ba962c8 to 6e0ff3d Compare February 12, 2025 00:24
@EvgeniiMekhanik EvgeniiMekhanik marked this pull request as ready for review February 12, 2025 00:46
@EvgeniiMekhanik
Copy link
Contributor Author

I also think about using assert_func in cache, but In this case we can't use parametrize class. (Because assert function depends on H2/HTTP). May be you have any idea

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