From 4efbc7071a0d09a8fd0d8c63ec0004bba603d41a Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Tue, 10 Jul 2012 22:47:49 +0000 Subject: [PATCH] Allow compilation with -Werror=format-security option --- ext/puma_http11/ext_help.h | 4 ++-- ext/puma_http11/puma_http11.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/puma_http11/ext_help.h b/ext/puma_http11/ext_help.h index 08c0e1e2..80b433f0 100644 --- a/ext/puma_http11/ext_help.h +++ b/ext/puma_http11/ext_help.h @@ -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 diff --git a/ext/puma_http11/puma_http11.c b/ext/puma_http11/puma_http11.c index ba07b0ba..82a4705c 100644 --- a/ext/puma_http11/puma_http11.c +++ b/ext/puma_http11/puma_http11.c @@ -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)); }