Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 64c6013

Browse files
ON-17066: fix argument passing to onload-spawned shrub controller
Without this patch, if any of the optional arguments weren't wanted, it would be replaced by NULL. This would be interpreted as the end of the argument list, so all other arguments after that point would be ignored.
1 parent 6994a99 commit 64c6013

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

‎src/driver/linux_onload/shrub_fns.c‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,34 @@ static int shrub_spawn_server(char* controller_id, bool debug,
9797
controller_id,
9898
"-D",
9999
"-K",
100-
debug ? "-d" : NULL,
101-
use_interrupts ? "-i" : NULL,
100+
/* slots for extra args */
101+
NULL,
102+
NULL,
103+
/* terminator */
102104
NULL
103105
};
104106
char* envp_flags = "";
105107
char* envp[] = {
106108
envp_flags,
107109
NULL
108110
};
111+
/* This must be the index of the first NULL slot in the argv array */
112+
int extra_arg_idx = 5;
109113

110114
path = kmalloc(PATH_MAX, GFP_KERNEL);
111115
if ( !path )
112116
return -ENOMEM;
113117

118+
if( debug )
119+
argv[extra_arg_idx++] = "-d";
120+
121+
if( use_interrupts )
122+
argv[extra_arg_idx++] = "-i";
123+
124+
/* We must create enough slots for extra arguments we pass to the shrub
125+
* controller, as otherwise we may not terminate the array correctly. */
126+
BUG_ON(extra_arg_idx >= (sizeof(argv) / sizeof(argv[0])));
127+
114128
spin_lock(&shrub_lock);
115129
strncpy(path, shrub_get_controller_path(), PATH_MAX);
116130
path[PATH_MAX - 1] = '0円';

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /