Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for kernel.pid_max > 65535 #13

Merged
merged 1 commit into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dfuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ int df_get_pid(const GDBusConnection *dcon)
*/
void df_print_process_info(int pid)
{
char proc_path[20]; // "/proc/(max5chars)/[exe|cmdline]"
char proc_path[15+DECIMAL_STR_MAX(int)]; // "/proc/(int)/[exe|cmdline]"
char name[PATH_MAX]; // for storing process and package name
char buf[PATH_MAX + MAXLEN]; // buffer for rpm/dpkg request
FILE *fp;
Expand Down
10 changes: 10 additions & 0 deletions src/dfuzzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@
/** Maximum length of strings containing D-Bus name, interface and object path */
#define MAXLEN 256

/* Returns the number of chars needed to format variables of the
* specified type as a decimal string. Adds in extra space for a
* negative '-' prefix (hence works correctly on signed
* types). Includes space for the trailing NUL. */
#define DECIMAL_STR_MAX(type) \
(2U+(sizeof(type) <= 1 ? 3U : \
sizeof(type) <= 2 ? 5U : \
sizeof(type) <= 4 ? 10U : \
sizeof(type) <= 8 ? 20U : sizeof(int[-2*(sizeof(type) > 8)])))

/** Structure containing D-Bus name, object path and interface of process. */
struct fuzzing_target {
/* names on D-Bus have the most MAXLEN characters */
Expand Down