// A auth_domain_find is not matched by an auth_domain_put before an // error return. // // Confidence: Moderate // Copyright: (C) Gilles Muller, Julia Lawall, EMN, INRIA, DIKU. GPLv2. // URL: https://coccinelle.gitlabpages.inria.fr/website/rules/auth.html // Options: @r@ local idexpression n; position p1; @@ n = auth_domain_find@p1(...) // find the missing returns @t exists@ local idexpression n; statement S1; expression E; expression *ptr != NULL; type T; position r.p1,p2; @@ ( if ((n = auth_domain_find@p1(...)) == NULL) S1 | n = auth_domain_find@p1(...) ) ... when != auth_node_put(n) when != if (...) { <+... auth_node_put(n) ...+> } when != true n == NULL || ... when != n = (T)E when != E = n ( return \(0\|<+...n...+>\|ptr\); | return@p2 ...; ) // find the ones with no inconsistent paths @s@ local idexpression n; statement S1,S2; expression E,E1; expression *ptr != NULL; type T,T1; identifier l1,l2; position r.p1; @@ ( if ((n = auth_domain_find@p1(...)) == NULL) S1 | n = auth_domain_find@p1(...) ) <... when != auth_node_put(n) when != if (...) { <+... auth_node_put(n) ...+> } when != true n == NULL || ... when != n = (T)E when != E = n when != goto l1; if (n == NULL || ...) S2 ...> ( return \(0\|<+...n...+>\|ptr\); | + auth_node_put(n); return ...; | auth_node_put(n); | n = (T1)E1 | E1 = n | goto l2; ) @script:python depends on !s@ p1 << r.p1; p2 << t.p2; @@ print "* file: %s auth_domain_find %s return %s" % (p1[0].file,p1[0].line,p2[0].line)