Skip to content

Commit db0ecf2

Browse files
author
Alexey Botchkov
committed
MDEV-8032 [PATCH] audit plugin - csv output broken.
Symbols like TAB or NEWLINE should be escaped, which was forgotten in one place.
1 parent 6264451 commit db0ecf2

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

mysql-test/suite/plugins/r/server_audit.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ id
4545
2
4646
alter table t1 rename renamed_t1;
4747
set global server_audit_events='connect,query';
48+
select 1,
49+
2,
50+
3;
51+
1 2 3
52+
1 2 3
4853
insert into t2 values (1), (2);
4954
select * from t2;
5055
id
@@ -244,6 +249,7 @@ TIME,HOSTNAME,root,localhost,ID,ID,ALTER,test,t1,
244249
TIME,HOSTNAME,root,localhost,ID,ID,RENAME,test,t1|test.renamed_t1,
245250
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'alter table t1 rename renamed_t1',0
246251
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'set global server_audit_events=\'connect,query\'',0
252+
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'select 1, 2, 3',0
247253
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'insert into t2 values (1), (2)',0
248254
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'select * from t2',0
249255
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,test,'select * from t_doesnt_exist',ID

mysql-test/suite/plugins/t/server_audit.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ insert into t2 values (1), (2);
3535
select * from t2;
3636
alter table t1 rename renamed_t1;
3737
set global server_audit_events='connect,query';
38+
select 1,
39+
2,
40+
3;
3841
insert into t2 values (1), (2);
3942
select * from t2;
4043
--error ER_NO_SUCH_TABLE

plugin/server_audit/server_audit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,8 @@ static size_t escape_string(const char *str, unsigned int len,
11181118
*(result++)= '\\';
11191119
*(result++)= '\\';
11201120
}
1121+
else if (is_space(*str))
1122+
*(result++)= ' ';
11211123
else
11221124
*(result++)= *str;
11231125
str++;

0 commit comments

Comments
 (0)