summaryrefslogtreecommitdiff
path: root/lib/pattern.c
AgeCommit message (Collapse)Author
2020-05-23Do not read past the end of fmt_desc[]Bart Van Assche
Callers of parse_format() pass a size in bytes while the parse_format() function itself expects a number of elements. Fix this by making the fmt_desc[] array NULL-terminated. This patch fixes the following Coverity complaint: CID 300986 (#1 of 1): Out-of-bounds access (OVERRUN) overrun-buffer-arg: Overrunning array fmt_desc of 1 24-byte elements by passing it to a function which accesses it at element index 23 (byte offset 575) using argument 24U. Cc: Roman Pen <r.peniaev@gmail.com> Fixes: 634bd210c17a ("lib/pattern: add set of functions to parse combined pattern input") Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-05-23Fix spelling in a source code commentBart Van Assche
Change two occurrences of 'descritor' into 'descriptor' Cc: Roman Pen <r.peniaev@gmail.com> Fixes: 634bd210c17a ("lib/pattern: add set of functions to parse combined pattern input") Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2018-03-21Refactor #includes and headersSitsofe Wheeler
- Try and remove unneeded #include lines - Try and add #include lines that would allow the files to be built in a more standalone manner Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
2017-06-08Add strndup() function, if we don't have itJens Axboe
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2017-06-08pattern: Add support for files in buffer_pattern argument.Stephen Bates
It is useful to be able to initialize the buffer contents using an input file (e.g. when testing certain pathological patterns for compression). Add support to the buffer_pattern input argument for reading data from a file via enclosing the filename in ``''``. Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Logan Gunthorpe <logang@deltatee.com> Reviewed-By: Muli Ben-Yehuda <muli@lightbitslabs.com> Signed-off-by: Stephen Bates <sbates@raithlin.com> Signed-off-by: Jens Axboe <axboe@fb.com>
2017-04-26Make lib/pattern.c a stand-alone libraryTomohiro Kusumi
lib/pattern.c not having dependency on fio.h enables it to be a stand-alone library, which is useful for debugging purpose. In fact, most of the files under lib/ directory do things this way. This requires the previous commit. -- # cat ./test6.c #include <stdio.h> #include "lib/pattern.h" int main(void) { /* just to see if it compiles */ paste_format_inplace(NULL, 0, NULL, 0, NULL); return 0; } # gcc -Wall -g ./test6.c ./lib/pattern.c ./lib/strntol.c Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com> Signed-off-by: Jens Axboe <axboe@fb.com>
2015-12-28lib/pattern: include oslib/strcasestr.hJens Axboe
Signed-off-by: Jens Axboe <axboe@fb.com>
2015-09-04lib/pattern: add set of functions to parse combined pattern inputRoman Pen
The idea of this patch is to have several helpers to parse combined pattern input, which can consists of strings, numbers and formats. For example now pattern can be combined and look like this string: input : 0xdeadbeef"123"0xdeadface output: de ad be ef 31 32 33 de ad fa ce or input : -99"some string"0x66 output: 9d ff ff ff 73 6f 6d 65 20 73 74 72 69 6e 67 66 or with formats input : 0xdeadface0xffff%o output: de ad fa ce ff ff 00 00 00 00 00 00 00 00 where %o - offset of the block, reserved 8 bytes Space for formats is reserved in output buffer. When buffer will be ready to be written to disk - 'paste' callback should be called for each pattern format. Each callback is responsible for writing data inside the reserved space in the output buffer. Format array can be extended at any time, all you need is to provide the name of the format and correct 'paste' callback. Signed-off-by: Roman Pen <r.peniaev@gmail.com> Signed-off-by: Jens Axboe <axboe@fb.com>