History

player/command: limit user-data name splits to 100

It fixes stack-overflow with keys that contains hundreds of splits. 100 is more than enough for any valid use of user-data, normally key shouldn't contain more than a few splits. Found by OSS-Fuzz.

Kacper Michajłow committed 2 years ago

Commit 5b3b2271 parent 2b056c81 file · +4 −0Browse files

Unified · Split

player/command.c+4−0
@@ -3793,6 +3793,7 @@ struct udata_ctx { · 3792 unmodified lines
37933793 const char *path;
37943794 mpv_node *node;
37953795 void *ta_parent;
3796+ int depth;
37963797 };
37973798
37983799 static int do_op_udata(struct udata_ctx* ctx, int action, void *arg)
@@ -3905,6 +3906,8 @@ static int do_op_udata(struct udata_ctx* ctx, int action, void *arg) · 106 unmodified lines
39053906 .arg = act->arg,
39063907 };
39073908
3909+ if (nctx.depth++ > 100)
3910+ return M_PROPERTY_ERROR;
39083911 return do_op_udata(&nctx, M_PROPERTY_KEY_ACTION, &sub_act);
39093912 } else {
39103913 return do_op_udata(&nctx, act->action, act->arg);
@@ -3919,6 +3922,7 @@ static int do_list_udata(int item, int action, void *arg, void *ctx) · 8 unmodified lines
39193922 struct udata_ctx nctx = *(struct udata_ctx*)ctx;
39203923 nctx.node = &nctx.node->u.list->values[item];
39213924 nctx.ta_parent = nctx.node->u.list;
3925+ nctx.depth = 0;
39223926
39233927 return do_op_udata(&nctx, action, arg);
39243928 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t