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

TS-5097 Validate plugin argument count #1268

Merged
merged 1 commit into from Dec 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions proxy/Plugin.cc
Expand Up @@ -32,6 +32,8 @@
#include "Plugin.h"
#include "ts/ink_cap.h"

#define MAX_PLUGIN_ARGS 64

static const char *plugin_dir = ".";

typedef void (*init_func_t)(int argc, char *argv[]);
Expand Down Expand Up @@ -219,8 +221,8 @@ plugin_init(bool validateOnly)
{
ats_scoped_str path;
char line[1024], *p;
char *argv[64];
char *vars[64];
char *argv[MAX_PLUGIN_ARGS];
char *vars[MAX_PLUGIN_ARGS];
int argc;
int fd;
int i;
Expand Down Expand Up @@ -255,6 +257,11 @@ plugin_init(bool validateOnly)

// not comment or blank, so rip line into tokens
while (1) {
if (argc >= MAX_PLUGIN_ARGS) {
Warning("Exceeded max number of args (%d) for plugin: [%s]", MAX_PLUGIN_ARGS, argc > 0 ? argv[0] : "???");
break;
}

while (*p && ParseRules::is_wslfcr(*p)) {
++p;
}
Expand Down