@@ -537,9 +537,9 @@ int convert_to_int(const char c)
537537 * \param msr Pointer to modsec resource
538538 * \param capture If ON match will be saved
539539 * \param match Pointer to captured string
540- *\parm tx_n The tx number to save the data
540+ * \param tx_n The tx number to save the data
541541 *
542- * \retval 0 On Sucess|Fail
542+ * \retval 0 On sucess
543543 */
544544int set_match_to_tx (modsec_rec * msr , int capture , const char * match , int tx_n ) {
545545 assert (msr != NULL );
@@ -567,6 +567,41 @@ int set_match_to_tx(modsec_rec *msr, int capture, const char *match, int tx_n)
567567}
568568
569569
570+ /** \brief Set a match to tx.N safe mode
571+ *
572+ * \param msr Pointer to modsec resource
573+ * \param capture If ON match will be saved
574+ * \param match Pointer to captured string
575+ * \param match_len Length of the captured string even if it contains NUL bytes
576+ * \param tx_n The tx number to save the data
577+ *
578+ * \retval 0 On sucess
579+ */
580+ int set_match_to_tx_safe (modsec_rec * msr , int capture , const char * match , unsigned int match_len , int tx_n ) {
581+ assert (msr != NULL );
582+
583+ if (capture ) {
584+ msc_string * s = (msc_string * )apr_pcalloc (msr -> mp , sizeof (msc_string ));
585+
586+ if (s == NULL ) return -1 ;
587+
588+ s -> name = apr_psprintf (msr -> mp ,"%d" , tx_n );
589+ s -> name_len = strlen (s -> name );
590+ s -> value = apr_pstrmemdup (msr -> mp , match , match_len );
591+ if (s -> value == NULL ) return -1 ;
592+ s -> value_len = match_len ;
593+ apr_table_setn (msr -> tx_vars , s -> name , (void * )s );
594+
595+ if (msr -> txcfg -> debuglog_level >= 9 ) {
596+ msr_log (msr , 9 , "Added phrase match to TX.%d: %s" ,
597+ tx_n , log_escape_nq_ex (msr -> mp , s -> value , s -> value_len ));
598+ }
599+
600+ }
601+
602+ return 0 ;
603+ }
604+
570605/**
571606 * Parses a string that contains a name-value pair in the form "name=value".
572607 * IMP1 It does not check for whitespace between tokens.
0 commit comments