Linux Test Project
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com>
Cc: LTP List <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v3 04/16] API/cgroup: Implement tst_cg_load_config
Date: Thu, 17 Mar 2022 07:07:49 +0000	[thread overview]
Message-ID: <878rt958yz.fsf@suse.de> (raw)
In-Reply-To: <CADS1e3ff7dnQe8zByitszNhKViiOLOF-UfNtSbMsFkkSX5Sy7Q@mail.gmail.com>

Hello Luke,

>
> Thank you for pointing all these things out. I forgot about all the shenanigans that can happen when you don't sanity check string stuff :)
>
> A few solutions to creating the scanff format are:
> 1) pre-processor trick to concatenate defines into a string, something like this
> #define _tostr(str) #str
> #define tostr(str) _tostr(str)
> #define CONFIG_FORMAT "%" tostr(CTRL_NAME_MAX) "s\t%d\t%d\t%" tostr(PATH_MAX) "s\t%d\t%d\t%" tostr(NAME_MAX) "s"
>
> 2) just hardcode the lengths to avoid all of this nonsense above

I would have done 2 in this case, but you figured out 1, so feel free to
use that. In fact that would be a nice addition to LTP's standard macros
(but with TST_ prefix).

Just note that the maximum conversion length doesn't include
the null character. scanf will write the null character after the
maximum conversion length. Also I'm not sure the field length comes
after '%' or that you use 's' with a length; possibly it should be
'%c63' to scan a 64 byte null terminated string. However please double
check the man page.

>
> 3) just create the format at runtime

IIRC this is considered unsafe and will result in warnings and errors.

>
> I'm more or less asking what you think is best to avoid sending out all of the patches and then discussing this / if there is a better way. 
>

-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2022-03-17  7:33 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-04 23:18 [LTP] [PATCH v2 00/16] Expand Cgroup lib and modify controller tests Luke Nowakowski-Krijger
2022-03-04 23:18 ` [LTP] [PATCH v3 01/16] API/cgroup: Modify tst_cg_print_config for parsing and consumption Luke Nowakowski-Krijger
2022-03-04 23:18 ` [LTP] [PATCH 02/16] API/cgroup: Add option for specific pid to tst_cg_opts Luke Nowakowski-Krijger
2022-03-04 23:18 ` [LTP] [PATCH v2 03/16] API/cgroup: Add cgroup_find_root helper function Luke Nowakowski-Krijger
2022-03-04 23:18 ` [LTP] [PATCH v3 04/16] API/cgroup: Implement tst_cg_load_config Luke Nowakowski-Krijger
2022-03-07  9:05   ` Richard Palethorpe
2022-03-16 22:38     ` Luke Nowakowski-Krijger
2022-03-17  7:07       ` Richard Palethorpe [this message]
2022-04-27 17:38         ` Luke Nowakowski-Krijger
2022-04-28  9:17           ` Li Wang
2022-03-04 23:18 ` [LTP] [PATCH v2 05/16] API/cgroup: Add more controllers to tst_cgroup Luke Nowakowski-Krijger
2022-03-07 11:24   ` Richard Palethorpe
2022-03-16  9:35     ` Li Wang
2022-03-04 23:18 ` [LTP] [PATCH 06/16] API/cgroup: refuse to mount blkio when io controller is mounted Luke Nowakowski-Krijger
2022-03-16 10:01   ` Li Wang
2022-03-04 23:18 ` [LTP] [PATCH v2 07/16] testcases/lib: Implement tst_cgctl binary Luke Nowakowski-Krijger
2022-03-04 23:18 ` [LTP] [PATCH v3 08/16] controllers: Expand cgroup_lib shell library Luke Nowakowski-Krijger
2022-03-07 11:00   ` Richard Palethorpe
2022-03-07 11:39     ` Richard Palethorpe
2022-03-16  9:46       ` Li Wang
2022-03-16 21:46         ` Luke Nowakowski-Krijger
2022-03-17  5:38           ` Li Wang
2022-03-04 23:18 ` [LTP] [PATCH v2 09/16] controllers: Update cgroup_fj_* to use newer cgroup lib and test lib Luke Nowakowski-Krijger
2022-03-04 23:18 ` [LTP] [PATCH v2 10/16] controllers: Update memcg_control_test to newer test lib and cgroup lib Luke Nowakowski-Krijger
2022-03-04 23:18 ` [LTP] [PATCH v2 11/16] controllers: Update memcg/regression/* to new test " Luke Nowakowski-Krijger
2022-03-04 23:18 ` [LTP] [PATCH v2 12/16] controllers: Update memcg_stress_test to use newer " Luke Nowakowski-Krijger
2022-03-04 23:18 ` [LTP] [PATCH v2 13/16] controllers: update memcg/functional " Luke Nowakowski-Krijger
2022-03-04 23:18 ` [LTP] [PATCH v2 14/16] controllers: Update pids.sh " Luke Nowakowski-Krijger
2022-03-04 23:18 ` [LTP] [PATCH v2 15/16] controllers: update cpuset_regression_test.sh " Luke Nowakowski-Krijger
2022-03-04 23:18 ` [LTP] [PATCH 16/16] controllers: update cgroup_regression_test " Luke Nowakowski-Krijger
2022-03-16  9:09   ` Li Wang

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=878rt958yz.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=ltp@lists.linux.it \
    --cc=luke.nowakowskikrijger@canonical.com \
    /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