[ZBX-15107] Incorrect error handling in compile_filename_regexp() if file name regexp does not compile in logrt[], logrt.count[] items Created: 2018 Oct 31  Updated: 2024 Apr 10  Resolved: 2018 Nov 29

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent (G)
Affects Version/s: 4.0.1
Fix Version/s: 4.0.3rc1, 4.2.0alpha2, 4.2 (plan)

Type: Problem report Priority: Major
Reporter: Andris Mednis Assignee: Andris Mednis
Resolution: Fixed Votes: 0
Labels: logrt, regex
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

GNU/Linux


Issue Links:
Causes
caused by ZBX-13730 High CPU / Faliure to Match REGEX Closed
Team: Team A
Sprint: Sprint 46, Nov 2018
Story Points: 0.125

 Description   

If a logrt[] or logrt.count[] item is used with incorrect regular expression for file name (e.g. logrt[/home/zabbix40/test.log.*\,.*]') then compile_filename_regexp() prints a part of error message from uninitialized buffer.

For example in frontend user might see:

Cannot compile a regular expression describing filename pattern: Б́

instead of

Cannot compile a regular expression describing filename pattern: \ at end of pattern

Possible fix:

Index: src/zabbix_agent/logfiles.c
===================================================================
--- src/zabbix_agent/logfiles.c	(revision 86279)
+++ src/zabbix_agent/logfiles.c	(working copy)
@@ -1533,8 +1533,8 @@
  *                                                                            *
  * Parameters:                                                                *
  *     filename_regexp - [IN] regexp to be compiled                           *
- *     re              - [OUT] compiled regexp                             *
- *     err_msg         - [OUT] error message why regexp could not be       *
+ *     re              - [OUT] compiled regexp                                *
+ *     err_msg         - [OUT] error message why regexp could not be          *
  *                       compiled                                             *
  *                                                                            *
  * Return value: SUCCEED or FAIL                                              *
@@ -1546,10 +1546,8 @@
 
 	if (SUCCEED != zbx_regexp_compile(filename_regexp, re, &regexp_err))
 	{
-		char	err_buf[MAX_STRING_LEN];
-
 		*err_msg = zbx_dsprintf(*err_msg, "Cannot compile a regular expression describing filename pattern: %s",
-				err_buf);
+				regexp_err);
 		return FAIL;
 	}

 



 Comments   
Comment by Andris Mednis [ 2018 Nov 16 ]

Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-15107.

Comment by Andris Mednis [ 2018 Nov 27 ]

Fixed in versions:

  • pre-4.0.3rc1 r87319
  • pre-4.2.0alpha2 (trunk) r87320
Generated at Fri Apr 26 06:12:21 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.