mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-30 13:58:22 +00:00
libapparamor: Define a portable version of gnu basename
Since musl 1.2.5, basename(3) prototype is only provided in libgen.h (as mandated by POSIX) and not in strings.h. Also there is a major difference between the gnu basename and the one defined in libgen.h, the latter modify the argument string making them incompatible. Fix this by defining a portable version of basename using strchr.
This commit is contained in:
parent
74316fe152
commit
7fb040bde6
@ -1,5 +1,3 @@
|
||||
#define _GNU_SOURCE /* for glibc's basename version */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -7,6 +5,12 @@
|
||||
|
||||
#include <aalogparse.h>
|
||||
|
||||
static const char *basename(const char *path)
|
||||
{
|
||||
const char *p = strrchr(path, '/');
|
||||
return p ? p + 1 : path;
|
||||
}
|
||||
|
||||
int print_results(aa_log_record *record);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
Loading…
x
Reference in New Issue
Block a user