mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-30 22:05:27 +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:
@@ -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)
|
||||
|
Reference in New Issue
Block a user