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

ua: enforce magic cookie in Via branch #1102

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/re_fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ int pl_strcpy(const struct pl *pl, char *str, size_t size);
int pl_strdup(char **dst, const struct pl *src);
int pl_dup(struct pl *dst, const struct pl *src);
int pl_strcmp(const struct pl *pl, const char *str);
int pl_strncmp(const struct pl *pl, const char *str, size_t n);
int pl_strcasecmp(const struct pl *pl, const char *str);
int pl_cmp(const struct pl *pl1, const struct pl *pl2);
int pl_casecmp(const struct pl *pl1, const struct pl *pl2);
Expand Down
1 change: 1 addition & 0 deletions include/re_sip.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ enum {


/** SIP Via header */
#define RE_RFC3261_BRANCH_ID "z9hG4bK"
struct sip_via {
struct pl sentby;
struct sa addr;
Expand Down
22 changes: 22 additions & 0 deletions src/fmt/pl.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,28 @@ int pl_strcmp(const struct pl *pl, const char *str)
}


/**
* Compare n characters of a pointer-length object with a NULL-terminated
* string (case-sensitive)
*
* @param pl Pointer-length object
* @param str NULL-terminated string
* @param n number of characters that should be compared
*
* @return 0 if match, otherwise errorcode
*/
int pl_strncmp(const struct pl *pl, const char *str, size_t n)
{
if (!pl_isset(pl) || !str || !n)
return EINVAL;

if (pl->l < n)
return EINVAL;

return strncmp(pl->p, str, n) == 0 ? 0 : EINVAL;
}


/**
* Compare a pointer-length object with a NULL-terminated string
* (case-insensitive)
Expand Down
Loading