mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-07 18:52:30 +00:00
* Fixed a bug that caused 'execute*' commands to fail when trying to run a program without any arguments.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1187 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+27
-13
@@ -161,25 +161,39 @@ ExecFile::execute_object(const torrent::Object& rawArgs, int flags) {
|
||||
char valueBuffer[buffer_size];
|
||||
char* valueCurrent = valueBuffer;
|
||||
|
||||
const torrent::Object::list_type& args = rawArgs.as_list();
|
||||
if (rawArgs.is_list()) {
|
||||
const torrent::Object::list_type& args = rawArgs.as_list();
|
||||
|
||||
if (args.empty())
|
||||
throw torrent::input_error("Too few arguments.");
|
||||
if (args.empty())
|
||||
throw torrent::input_error("Too few arguments.");
|
||||
|
||||
for (torrent::Object::list_const_iterator itr = args.begin(), last = args.end(); itr != last; itr++, argsCurrent++) {
|
||||
if (argsCurrent == argsBuffer + max_args - 1)
|
||||
throw torrent::input_error("Too many arguments.");
|
||||
for (torrent::Object::list_const_iterator itr = args.begin(), last = args.end(); itr != last; itr++, argsCurrent++) {
|
||||
if (argsCurrent == argsBuffer + max_args - 1)
|
||||
throw torrent::input_error("Too many arguments.");
|
||||
|
||||
if (itr->is_string() && (!(flags & flag_expand_tilde) || *itr->as_string().c_str() != '~')) {
|
||||
*argsCurrent = const_cast<char*>(itr->as_string().c_str());
|
||||
if (itr->is_string() && (!(flags & flag_expand_tilde) || *itr->as_string().c_str() != '~')) {
|
||||
*argsCurrent = const_cast<char*>(itr->as_string().c_str());
|
||||
|
||||
} else {
|
||||
} else {
|
||||
*argsCurrent = valueCurrent;
|
||||
valueCurrent = print_object(valueCurrent, valueBuffer + buffer_size, &*itr, flags) + 1;
|
||||
|
||||
if (valueCurrent >= valueBuffer + buffer_size)
|
||||
throw torrent::input_error("Overflowed execute arg buffer.");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
const torrent::Object::string_type& args = rawArgs.as_string();
|
||||
|
||||
if ((flags & flag_expand_tilde) && args.c_str()[0] == '~') {
|
||||
*argsCurrent = valueCurrent;
|
||||
valueCurrent = print_object(valueCurrent, valueBuffer + buffer_size, &*itr, flags) + 1;
|
||||
valueCurrent = print_object(valueCurrent, valueBuffer + buffer_size, &rawArgs, flags) + 1;
|
||||
} else {
|
||||
*argsCurrent = const_cast<char*>(args.c_str());
|
||||
}
|
||||
|
||||
if (valueCurrent >= valueBuffer + buffer_size)
|
||||
throw torrent::input_error("Overflowed execute arg buffer.");
|
||||
}
|
||||
argsCurrent++;
|
||||
}
|
||||
|
||||
*argsCurrent = NULL;
|
||||
|
||||
Reference in New Issue
Block a user