Permalink
Browse files

Merge pull request #120 from tjouan/tj/allow-compilation-with-format-…

…security-error

Allow compilation with -Werror=format-security option
  • Loading branch information...
2 parents 35de0e2 + a5e1a39 commit 2ddb22426e1b9f516a6b4c96a5ab81ef80cc8600 @macournoyer committed Aug 7, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 ext/thin_parser/thin.c
@@ -47,7 +47,7 @@ static VALUE global_path_info;
#define DEF_MAX_LENGTH(N,length) const size_t MAX_##N##_LENGTH = length; const char *MAX_##N##_LENGTH_ERR = "HTTP element " # N " is longer than the " # length " allowed length."
/** Validates the max length of given input and throws an HttpParserError exception if over. */
-#define VALIDATE_MAX_LENGTH(len, N) if(len > MAX_##N##_LENGTH) { rb_raise(eHttpParserError, MAX_##N##_LENGTH_ERR); }
+#define VALIDATE_MAX_LENGTH(len, N) if(len > MAX_##N##_LENGTH) { rb_raise(eHttpParserError, "%s", MAX_##N##_LENGTH_ERR); }
/** Defines global strings in the init method. */
#define DEF_GLOBAL(N, val) global_##N = rb_obj_freeze(rb_str_new2(val)); rb_global_variable(&global_##N)
@@ -329,15 +329,15 @@ VALUE Thin_HttpParser_execute(VALUE self, VALUE req_hash, VALUE data, VALUE star
dlen = RSTRING_LEN(data);
if(from >= dlen) {
- rb_raise(eHttpParserError, "Requested start is after data buffer end.");
+ rb_raise(eHttpParserError, "%s", "Requested start is after data buffer end.");
} else {
http->data = (void *)req_hash;
thin_http_parser_execute(http, dptr, dlen, from);
VALIDATE_MAX_LENGTH(http_parser_nread(http), HEADER);
if(thin_http_parser_has_error(http)) {
- rb_raise(eHttpParserError, "Invalid HTTP format, parsing fails.");
+ rb_raise(eHttpParserError, "%s", "Invalid HTTP format, parsing fails.");
} else {
return INT2FIX(http_parser_nread(http));
}

0 comments on commit 2ddb224

Please sign in to comment.