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

Fixed validation of subscriber_parameters with string_ids true in vid… #2297

Merged
merged 2 commits into from
Jul 28, 2020
Merged

Fixed validation of subscriber_parameters with string_ids true in vid… #2297

merged 2 commits into from
Jul 28, 2020

Conversation

ZeXtrasJay
Copy link

It seems the field "feed" inside stream is always validated as a integer, while it could also be a string.

@januscla
Copy link

Thanks for your contribution, @ZeXtrasJay! Please make sure you sign our CLA, as it's a required step before we can merge this.

@lminiero
Copy link
Member

Mh I don't think that's the way to go. We already have definitions of feed as integer or string:

static struct janus_json_parameter feedopt_parameters[] = {
	{"feed", JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE}
};
static struct janus_json_parameter feedstropt_parameters[] = {
	{"feed", JSON_STRING, 0}
};

For all requests that involve a feed or id, we actually decouple those from all the other properties, in order to validate the feed/id first depending on what they are, and only then validate the rest. The same should be done for subscriber_stream_parameters, or you end up with huge duplicates like the one you created here.

@ZeXtrasJay
Copy link
Author

@lminiero I've updated the PR, but i'm not 100% sure it's what you meant

@lminiero
Copy link
Member

lminiero commented Jul 28, 2020

Actually I think the only thing you need to do in this patch is removing feed from the definition of the subscriber_stream_parameters[] properties: in fact, we already have the right checks in both the for loops (we check subscriber_stream_parameters first, and then feed separately to see if it's an integer or string). All the other changes seem unneeded.

@ZeXtrasJay
Copy link
Author

@lminiero
I've simplified the patch, but i also found a memory leak (two commits)

@@ -1670,7 +1670,7 @@ static struct janus_json_parameter subscriber_parameters[] = {
{"temporal_layer", JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE},
};
static struct janus_json_parameter subscriber_stream_parameters[] = {
{"feed", JANUS_JSON_INTEGER, JANUS_JSON_PARAM_REQUIRED | JANUS_JSON_PARAM_POSITIVE},
//~ {"feed", JANUS_JSON_INTEGER, JANUS_JSON_PARAM_REQUIRED | JANUS_JSON_PARAM_POSITIVE},
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the line entirely, rather than just commenting it out.

@lminiero
Copy link
Member

I've simplified the patch, but i also found a memory leak (two commits)

Good catch, it was in the previous error management code but not here, thanks 👍

@ZeXtrasJay
Copy link
Author

Removed the line 👍

@lminiero
Copy link
Member

Thanks, merging then! ✌️

@lminiero lminiero merged commit dccd99f into meetecho:multistream Jul 28, 2020
lminiero pushed a commit that referenced this pull request Sep 2, 2020
#2297)

* Removed validation of "feed" parameter of subscriber_stream_parameters in janus_vdeoroom.c since it's already validated independently
* Fixed memory leak in janus_videoroom.c in case "feed_id" parameter is invalid

Co-authored-by: Davide Baldo <[email protected]>
lminiero pushed a commit that referenced this pull request Oct 30, 2020
#2297)

* Removed validation of "feed" parameter of subscriber_stream_parameters in janus_vdeoroom.c since it's already validated independently
* Fixed memory leak in janus_videoroom.c in case "feed_id" parameter is invalid

Co-authored-by: Davide Baldo <[email protected]>
lminiero pushed a commit that referenced this pull request Dec 9, 2020
#2297)

* Removed validation of "feed" parameter of subscriber_stream_parameters in janus_vdeoroom.c since it's already validated independently
* Fixed memory leak in janus_videoroom.c in case "feed_id" parameter is invalid

Co-authored-by: Davide Baldo <[email protected]>
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.

4 participants