Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

2.x standalone fails to link since ap_map_http_request_error() is not exported as APR function

Aperta
#3,451 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
c
Ambito
build-system

Direzione di ricerca

Inizia da apache2/apache2_io.c, leggendo in particolare read_request_body e il comando di compilazione standalone mostrato nel report. Controlla come viene fornito ap_map_http_request_error per le compilazioni standalone e verifica il risultato collegando la libreria standalone con l’integrazione SPOA ModSecurity; il lavoro è concluso quando il collegamento termina senza il riferimento non definito.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

2.x

To integrate the ModSecurity 2.x with HAProxy, I compiled the standalone/ .
It compiles successfully, but when linked with SPOA published at
https://github.com/haproxy/spoa-modsecurity/
link phase fails with:

LANG=C make MODSEC_INC=/usr/local/src/modsecurity/ModSecurity/INSTALL/include MODSEC_LIB=/usr/local/src/modsecurity/ModSecurity/INSTALL/lib APACHE2_INC=/usr/include/httpd APR_INC=/usr/include/apr-1 | tee log.build
cc  -o modsecurity spoa.o modsec_wrapper.o /usr/local/src/modsecurity/ModSecurity/INSTALL/lib/standalone.a -lpthread  -levent -levent_pthreads -lcurl -lapr-1 -laprutil-1 -lxml2 -lpcre -lpcre2-8 -lyajl
/usr/local/src/modsecurity/ModSecurity/INSTALL/lib/standalone.a(standalone_la-apache2_io.o): In function `read_request_body':
/usr/local/src/modsecurity/ModSecurity/standalone/../apache2/apache2_io.c:237: undefined reference to 
`ap_map_http_request_error'
collect2: error: ld returned 1 exit status
make: *** [Makefile:43: modsecurity] Error 1

The function ap_map_http_request_error() is internal to httpd and not published to APR libraries.

The patch below fixes this, but I feel somewhat uncomfortable.

diff --git a/apache2/apache2_io.c b/apache2/apache2_io.c
index 8deeb01c..383439a3 100644
--- a/apache2/apache2_io.c
+++ b/apache2/apache2_io.c
@@ -175,6 +175,42 @@ apr_status_t input_filter(ap_filter_t *f, apr_bucket_brigade *bb_out,
     return APR_SUCCESS;
 }

+/* Ack. ap_map_http_request_error() is not an apr function, so it is
+ * not public in a library. Include it here.
+ */
+/*
+ * Map specific APR codes returned by the filter stack to HTTP error
+ * codes, or the default status code provided. Use it as follows:
+ *
+ * return ap_map_http_request_error(rv, HTTP_BAD_REQUEST);
+ *
+ * If the filter has already handled the error, AP_FILTER_ERROR will
+ * be returned, which is cleanly passed through.
+ *
+ * These mappings imply that the filter stack is reading from the
+ * downstream client, the proxy will map these codes differently.
+ */
+AP_DECLARE(int) ap_map_http_request_error(apr_status_t rv, int status)
+{
+    switch (rv) {
+    case AP_FILTER_ERROR:
+        return AP_FILTER_ERROR;
+
+    case APR_ENOSPC:
+        return HTTP_REQUEST_ENTITY_TOO_LARGE;
+
+    case APR_ENOTIMPL:
+        return HTTP_NOT_IMPLEMENTED;
+
+    case APR_TIMEUP:
+    case APR_ETIMEDOUT:
+        return HTTP_REQUEST_TIME_OUT;
+
+    default:
+        return status;
+    }
+}
+
 /**
  * Reads request body from a client.
  */
Lingua principale
C++
Stelle
9.8k
Fork
1.8k
Merge medio
2h 46m
PR unite (30g)
1

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di owasp-modsecurity/ModSecurity

Tutte le issue di owasp-modsecurity/ModSecurity

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.