diff options
| author | Oleg Nesterov <[email protected]> | 2013-04-29 23:18:10 +0000 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2013-04-30 01:28:19 +0000 |
| commit | 095d141b2e40665289d44a42d387ffac2841ef82 (patch) | |
| tree | 3a70ce1eb403955647ab80d1089ea47e95afd9f3 /lib/dynamic_debug.c | |
| parent | lib/int_sqrt.c: optimize square root algorithm (diff) | |
| download | kernel-095d141b2e40665289d44a42d387ffac2841ef82.tar.gz kernel-095d141b2e40665289d44a42d387ffac2841ef82.zip | |
argv_split(): teach it to handle mutable strings
argv_split() allocates argv[count_argc(str)] array and assumes that it
will find the same number of arguments later. This is obviously wrong if
this string can be changed, say, by sysctl.
With this patch argv_split() kstrndup's the whole string and does not
split it, we simply replace the spaces with zeroes and keep the allocated
memory in argv[-1] for argv_free(arg).
We do not use argv[0] because:
- str can be all-spaces or empty. In fact this case is fine,
we could kfree() it before return, but:
- str can have a space at the start, and we can not rely on
kstrndup(skip_spaces(str)) because it can equally race if
this string is mutable.
Also, simplify count_argc() and kill the no longer used skip_arg().
Signed-off-by: Oleg Nesterov <[email protected]>
Cc: Andi Kleen <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'lib/dynamic_debug.c')
0 files changed, 0 insertions, 0 deletions
