From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: asarmanow@gmail.com
Subject: Re: [PATCH v2 2/2] batctl: Add JSON debug commands
Date: Mon, 10 May 2021 16:22:21 +0200 [thread overview]
Message-ID: <2573355.sAYfyd1srq@ripper> (raw)
In-Reply-To: <8402068.deHtlMXeMU@ripper>
[-- Attachment #1: Type: text/plain, Size: 873 bytes --]
On Monday, 10 May 2021 12:14:10 CEST Sven Eckelmann wrote:
> void sanitize_string(const char *str)
> {
> while (*str) {
> if (*str == '"')
> puts("\"");
> else if (*str == '\\')
> puts("\\\\");
> else if (!isprint(*str))
> printf("\\x%02x", *str);
> else
> putc(*str);
>
> str++;
> }
> }
Should have tested this. It should be more like:
void sanitize_string(const char *str)
{
while (*str) {
if (*str == '"' || *str == '\\') {
putchar('\\');
putchar(*str);
} else if (!isprint(*str)) {
printf("\\x%02x", *str);
} else {
putchar(*str);
}
}
}
Kind regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2021-05-10 14:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-07 17:14 [PATCH v2 2/2] batctl: Add JSON debug commands Alexander Sarmanow
2021-05-07 18:58 ` Sven Eckelmann
2021-05-10 7:58 ` asarmanow
2021-05-10 10:14 ` Sven Eckelmann
2021-05-10 14:22 ` Sven Eckelmann [this message]
2021-05-07 19:08 ` Sven Eckelmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2573355.sAYfyd1srq@ripper \
--to=sven@narfation.org \
--cc=asarmanow@gmail.com \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox