1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,security.SetgidSetuidOrder -analyzer-output=text -verify %s
15 if (setuid(getuid()) == -1) // expected-note{{Assuming the condition is false}} \
16 // expected-note{{Taking false branch}}
18 if (setuid(getuid()) == -1) // expected-note{{Call to 'setuid' found here that removes superuser privileges}} \
19 // expected-note{{Assuming the condition is false}} \
20 // expected-note{{Taking false branch}}
22 if (setgid(getgid()) == -1) // expected-warning{{A 'setgid(getgid())' call following a 'setuid(getuid())' call is likely to fail}} \
23 // expected-note{{A 'setgid(getgid())' call following a 'setuid(getuid())' call is likely to fail}}
28 if (setuid(getuid()) == -1) // expected-note{{Call to 'setuid' found here that removes superuser privileges}} \
29 // expected-note 2 {{Assuming the condition is false}} \
30 // expected-note 2 {{Taking false branch}}
32 if (setgid(getgid()) == -1) // expected-warning{{A 'setgid(getgid())' call following a 'setuid(getuid())' call is likely to fail}} \
33 // expected-note{{A 'setgid(getgid())' call following a 'setuid(getuid())' call is likely to fail}} \
34 // expected-note{{Assuming the condition is false}} \
35 // expected-note{{Taking false branch}}
37 if (setuid(getuid()) == -1) // expected-note{{Call to 'setuid' found here that removes superuser privileges}} \
38 // expected-note{{Assuming the condition is false}} \
39 // expected-note{{Taking false branch}}
41 if (setgid(getgid()) == -1) // expected-warning{{A 'setgid(getgid())' call following a 'setuid(getuid())' call is likely to fail}} \
42 // expected-note{{A 'setgid(getgid())' call following a 'setuid(getuid())' call is likely to fail}}
47 return setuid(getuid()); // expected-note{{Call to 'setuid' found here that removes superuser privileges}}
51 return setgid(getgid()); // expected-warning{{A 'setgid(getgid())' call following a 'setuid(getuid())' call is likely to fail}} \
52 // expected-note{{A 'setgid(getgid())' call following a 'setuid(getuid())' call is likely to fail}}
56 if (f_setuid() == -1) // expected-note{{Assuming the condition is false}} \
57 // expected-note{{Calling 'f_setuid'}} \
58 // expected-note{{Returning from 'f_setuid'}} \
59 // expected-note{{Taking false branch}}
61 if (f_setgid() == -1) // expected-note{{Calling 'f_setgid'}}
66 if (setuid(getuid()) == 0) { // expected-note{{Assuming the condition is true}} \
67 // expected-note{{Call to 'setuid' found here that removes superuser privileges}} \
68 // expected-note{{Taking true branch}}
69 if (setgid(getgid()) == 0) { // expected-warning{{A 'setgid(getgid())' call following a 'setuid(getuid())' call is likely to fail}} \
70 // expected-note{{A 'setgid(getgid())' call following a 'setuid(getuid())' call is likely to fail}}