Skip to content

Commit

Permalink
Fix wrong limits.h include (should be linux/limits.h)
Browse files Browse the repository at this point in the history
ARG_MAX and PATH_MAX are defined on POSIX.1-2017's limits.h(0p)[1], on
linux/limits.h and on musl's limits.h, but not on glibc's limits.h (nor
on any of its includes):

    $ grep -F -e ' ARG_MAX' -e ' PATH_MAX' /usr/include/limits.h \
      /usr/include/linux/limits.h /usr/lib/musl/include/limits.h
    /usr/include/linux/limits.h:#define ARG_MAX       131072        /* # bytes of args + environ for exec() */
    /usr/include/linux/limits.h:#define PATH_MAX        4096        /* # chars in a path name including nul */
    /usr/lib/musl/include/limits.h:#define PATH_MAX 4096
    /usr/lib/musl/include/limits.h:#define ARG_MAX 131072

Environment:

    $ grep '^NAME' /etc/os-release
    NAME="Artix Linux"
    $ pacman -Qo /usr/include/limits.h /usr/include/linux/limits.h \
      /usr/lib/musl/include/limits.h
    /usr/include/limits.h is owned by glibc 2.33-5
    /usr/include/linux/limits.h is owned by linux-api-headers 5.12.3-1
    /usr/lib/musl/include/limits.h is owned by musl 1.2.2-1

Files that use the macros:

    $ git grep -Fl -e ARG_MAX -e PATH_MAX -- src
    src/firejail/cmdline.c
    src/firejail/firejail.h
    src/libtrace/libtrace.c
    src/libtracelog/libtracelog.c

Note: No other macro from linux/limits.h appears to be used.

Note2: The build works even without including any limits.h on the files
that this commit changes, so there is probably another include on them
that ends up defining ARG_MAX/PATH_MAX.

Relates to #4578.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
  • Loading branch information
kmk3 committed Sep 28, 2021
1 parent ac78207 commit f4171df
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/libtrace/libtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <string.h>
#include <dlfcn.h>
#include <sys/types.h>
#include <limits.h>
#include <linux/limits.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
Expand Down
2 changes: 1 addition & 1 deletion src/libtracelog/libtracelog.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <sys/stat.h>
#include <syslog.h>
#include <dirent.h>
#include <limits.h>
#include <linux/limits.h>
#include "../include/rundefs.h"

//#define DEBUG
Expand Down

0 comments on commit f4171df

Please sign in to comment.