/src/qubes-os/qubes-core-qrexec/libqrexec/replace.c
Line | Count | Source |
1 | | /* |
2 | | * The Qubes OS Project, http://www.qubes-os.org |
3 | | * |
4 | | * Copyright (C) 2020 Paweł Marczewski <pawel@invisiblethingslab.com> |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or |
7 | | * modify it under the terms of the GNU General Public License |
8 | | * as published by the Free Software Foundation; either version 2 |
9 | | * of the License, or (at your option) any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program; if not, write to the Free Software |
18 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
19 | | * |
20 | | */ |
21 | | |
22 | | #include "libqrexec-utils.h" |
23 | | |
24 | 1.36k | void do_replace_chars(char *buf, int len) { |
25 | 1.36k | int i; |
26 | 1.36k | unsigned char c; |
27 | | |
28 | 75.6k | for (i = 0; i < len; i++) { |
29 | 74.2k | c = buf[i]; |
30 | 74.2k | if ((c < '\040' || c > '\176') && /* not printable ASCII */ |
31 | 74.2k | (c != '\t') && /* not tab */ |
32 | 74.2k | (c != '\n') && /* not newline */ |
33 | 74.2k | (c != '\r') && /* not return */ |
34 | 74.2k | (c != '\b') && /* not backspace */ |
35 | 74.2k | (c != '\a')) /* not bell */ |
36 | 53.1k | buf[i] = '_'; |
37 | 74.2k | } |
38 | 1.36k | } |