1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Allow compilation with -Werror=format-security option

This commit is contained in:
Thibault Jouan 2012-07-10 22:47:49 +00:00
parent ca21111666
commit 4efbc7071a
2 changed files with 5 additions and 5 deletions

View file

@ -1,9 +1,9 @@
#ifndef ext_help_h
#define ext_help_h
#define RAISE_NOT_NULL(T) if(T == NULL) rb_raise(rb_eArgError, "NULL found for " # T " when shouldn't be.");
#define RAISE_NOT_NULL(T) if(T == NULL) rb_raise(rb_eArgError, "%s", "NULL found for " # T " when shouldn't be.");
#define DATA_GET(from,type,name) Data_Get_Struct(from,type,name); RAISE_NOT_NULL(name);
#define REQUIRE_TYPE(V, T) if(TYPE(V) != T) rb_raise(rb_eTypeError, "Wrong argument type for " # V " required " # T);
#define REQUIRE_TYPE(V, T) if(TYPE(V) != T) rb_raise(rb_eTypeError, "%s", "Wrong argument type for " # V " required " # T);
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#ifdef DEBUG

View file

@ -41,7 +41,7 @@ static VALUE global_request_path;
#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_str_new2(val); rb_global_variable(&global_##N)
@ -380,7 +380,7 @@ VALUE HttpParser_execute(VALUE self, VALUE req_hash, VALUE data, VALUE start)
if(from >= dlen) {
rb_free_chars(dptr);
rb_raise(eHttpParserError, "Requested start is after data buffer end.");
rb_raise(eHttpParserError, "%s", "Requested start is after data buffer end.");
} else {
http->request = req_hash;
http_parser_execute(http, dptr, dlen, from);
@ -389,7 +389,7 @@ VALUE HttpParser_execute(VALUE self, VALUE req_hash, VALUE data, VALUE start)
VALIDATE_MAX_LENGTH(http_parser_nread(http), HEADER);
if(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));
}