Skip to content

Commit

Permalink
Trim whitespace before searching for operation type
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/modules/rlm_sql/rlm_sql.c
  • Loading branch information
arr2036 committed Feb 1, 2017
1 parent f62bec1 commit 183c582
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/modules/rlm_sql/rlm_sql.c
Expand Up @@ -154,19 +154,26 @@ static ssize_t sql_xlat(UNUSED TALLOC_CTX *ctx, char **out, UNUSED size_t outlen
rlm_sql_t const *inst = mod_inst;
sql_rcode_t rcode;
ssize_t ret = 0;
size_t len = 0;
char const *p;

handle = fr_connection_get(inst->pool, request); /* connection pool should produce error */
if (!handle) return 0;

rlm_sql_query_log(inst, request, NULL, fmt);

/*
* Trim whitespace for the prefix check
*/
for (p = query; is_whitespace(p); p++);

/*
* If the query starts with any of the following prefixes,
* then return the number of rows affected
*/
if ((strncasecmp(fmt, "insert", 6) == 0) ||
(strncasecmp(fmt, "update", 6) == 0) ||
(strncasecmp(fmt, "delete", 6) == 0)) {
if ((strncasecmp(p, "insert", 6) == 0) ||
(strncasecmp(p, "update", 6) == 0) ||
(strncasecmp(p, "delete", 6) == 0)) {
int numaffected;

rcode = rlm_sql_query(inst, request, &handle, fmt);
Expand Down

0 comments on commit 183c582

Please sign in to comment.