Commit Graph

11 Commits

Author SHA1 Message Date
Joshua Brindle
9fbfeb43d2 symtab_datum is only 32 bits so casting triggers increase alignment warning, cast to void first to avoid that 2016-04-22 09:16:30 -04:00
Chris PeBenito
e7f12a17d8 Reduce diff size between files copied from checkpolicy and libqpol.
Try to make future updates easier.
2016-03-28 16:34:35 -04:00
Richard Haines
dd29dc9c43 setools-V4: libqpol policy V30 updates (xen/xperm statements)
Updated libqpol services to use the latest checkpolicy 2.4 source
files to support Xen and extended permissions (allowxperm etc.).

TODO: Add support for querying the xperm values.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
2016-03-21 10:56:37 -04:00
Chris PeBenito
0192ff6ddd Restore abort() use.
Otherwise -NDEBUG builds get compile errors.
2015-02-05 13:28:08 -05:00
Chris PeBenito
79320ba0cc Update parsers to checkpolicy 2.4.
Start dropping ancient psid support and other unused #ifdefs.
2015-02-05 13:05:55 -05:00
Nicolas Iooss
edca1ac4c7 Treat literal strings as constant
Literal strings are located in read-only memory and should be "const
char*".  "gcc -Wwrite-strings" warns when using non-const literal
strings with messages like:

    libqpol/policy_parse.y: In function 'yyparse':
    libqpol/policy_parse.y:381:21: warning: passing argument 1 of
    'insert_id' discards 'const' qualifier from pointer target type
         { if (insert_id("T",0)) return -1; }
                     ^

Fix these warnings by using "const char*" instead of "char*" for some
function parameters.

This makes gcc report other warnings about hashtab_search (from
libsepol).  This function incorrectly defines its second parameter as
"char *const key" instead of "const char* key" (this fact is hidden
behind hashtab_key_t typedef).
2014-11-02 13:02:59 -05:00
Nicolas Iooss
2994d1ca1d Cast the 2nd parameter of hashtab_search to hashtab_key_t
"gcc -Wwrite-strings" reported warnings when using hashtab_search (from
libsepol) with string literals as its second parameter is a non-constant
string.

Indeed /usr/include/sepol/policydb/hashtab.h contains:

    typedef char *hashtab_key_t;
    /* ... */
    extern hashtab_datum_t hashtab_search(hashtab_t h, const hashtab_key_t k);

This means the second parameter is "char *const k", not "const char *k".
As a consequence:

* Casting to "const hashtab_key_t" leads to misunderstanding the code.
* "const char*" variables need to be explicitly casted to "char*" or
  "hashtab_key_t" before calling hashtab_search.
* When using "gcc -Wwrite-strings", literal strings need to be casted to
  "char*" or "hashtab_key_t" before calling hashtab_search.
* "gcc -Wcast-qual" reports an awful amount of warnings due to
  const-to-nonconst pointer casts.

Add missing casts to hashtab_key_t to help finding real bugs in
setools/libqpol with gcc flags.
2014-11-02 13:02:58 -05:00
Nicolas Iooss
b8f6292bfa Use abort() instead of assert(0) to mark unreachable code
"python setup.py build" compiles libqpol with -DNDEBUG, which disables
the effect of assert(0).  abort() is not affected by NDEBUG, so use it
instead.

This fixes gcc warnings like this:

    libqpol/module_compiler.c: In function 'declare_role':
    libqpol/module_compiler.c:314:1: warning: control reaches end of
    non-void function [-Wreturn-type]
2014-11-02 13:02:58 -05:00
Nicolas Iooss
b029b164c4 Fix comparisons between numbers with mismatched signedness in libqpol
Fix warnings reported by "gcc -Wsign-compare"
2014-11-02 13:02:58 -05:00
Nicolas Iooss
35722ab22d Improve libqpol yyerror/yywarn prototypes
* Add printf format specifier for yyerror2 to be able to use
  "gcc -Wformat-security"
* Constify message string to avoid gcc warnings about casting string
  literals to non-const char*.
2014-11-02 13:02:10 -05:00
Chris PeBenito
8363f8edf7 Import libqpol from setools3.
Break setools3 dependence. Also fix SWIG wrapper to work with SWIG 2.x.
2014-10-24 21:00:24 -04:00