• R/O
  • SSH
  • HTTPS

caitsith: Commit


Commit MetaInfo

Revision165 (tree)
Time2015-08-03 21:50:27
Authorkumaneko

Log Message

Limit wildcard recursion depth.

Change Summary

Incremental Difference

--- trunk/caitsith-patch/security/caitsith/policy_io.c (revision 164)
+++ trunk/caitsith-patch/security/caitsith/policy_io.c (revision 165)
@@ -1362,6 +1362,7 @@
13621362 */
13631363 static bool cs_correct_word(const char *string)
13641364 {
1365+ u8 recursion = 20;
13651366 const char *const start = string;
13661367 u8 in_repetition = 0;
13671368 if (!*string)
@@ -1390,16 +1391,22 @@
13901391 goto out;
13911392 }
13921393 switch (c) {
1393- case '$': /* "\$" */
13941394 case '+': /* "\+" */
13951395 case '?': /* "\?" */
1396+ case 'x': /* "\x" */
1397+ case 'a': /* "\a" */
1398+ case '-': /* "\-" */
1399+ continue;
1400+ }
1401+ /* Reject too deep wildcard that consumes too much stack. */
1402+ if (!recursion--)
1403+ goto out;
1404+ switch (c) {
13961405 case '*': /* "\*" */
13971406 case '@': /* "\@" */
1398- case 'x': /* "\x" */
1407+ case '$': /* "\$" */
13991408 case 'X': /* "\X" */
1400- case 'a': /* "\a" */
14011409 case 'A': /* "\A" */
1402- case '-': /* "\-" */
14031410 continue;
14041411 case '{': /* "/\{" */
14051412 if (string - 3 < start || *(string - 3) != '/')
--- trunk/caitsith-patch/caitsith/policy_io.c (revision 164)
+++ trunk/caitsith-patch/caitsith/policy_io.c (revision 165)
@@ -1319,6 +1319,7 @@
13191319 */
13201320 static bool cs_correct_word(const char *string)
13211321 {
1322+ u8 recursion = 20;
13221323 const char *const start = string;
13231324 u8 in_repetition = 0;
13241325 if (!*string)
@@ -1347,16 +1348,22 @@
13471348 goto out;
13481349 }
13491350 switch (c) {
1350- case '$': /* "\$" */
13511351 case '+': /* "\+" */
13521352 case '?': /* "\?" */
1353+ case 'x': /* "\x" */
1354+ case 'a': /* "\a" */
1355+ case '-': /* "\-" */
1356+ continue;
1357+ }
1358+ /* Reject too deep wildcard that consumes too much stack. */
1359+ if (!recursion--)
1360+ goto out;
1361+ switch (c) {
13531362 case '*': /* "\*" */
13541363 case '@': /* "\@" */
1355- case 'x': /* "\x" */
1364+ case '$': /* "\$" */
13561365 case 'X': /* "\X" */
1357- case 'a': /* "\a" */
13581366 case 'A': /* "\A" */
1359- case '-': /* "\-" */
13601367 continue;
13611368 case '{': /* "/\{" */
13621369 if (string - 3 < start || *(string - 3) != '/')
Show on old repository browser