Commit graph

23 commits

Author SHA1 Message Date
Karel Zak
91a484feba lsfd: remove strcpy(), keep things based on sizeof()
* use safe xstrncpy() rather than strcpy()
* use sizeof() for static buffers rather than macro with real size
  (this solution is more robust for future code changes)
* use xcalloc() to zeroize allocated memory

Signed-off-by: Karel Zak <kzak@redhat.com>
2023-01-20 15:20:55 +01:00
Masatake YAMATO
546b26b101 lsfd: (filter): accept '.' used in column names
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2022-09-12 21:48:45 +09:00
Masatake YAMATO
28c20d30c0 lsfd: fix crash triggered by an empty filter expression
$ lsfd -Q ''

or

  $ lsfd --filter ''

made lsfd process crash.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2022-07-28 13:09:03 +09:00
Masatake YAMATO
cdbb34d0db lsfd: (filter): parse "" in filter expression correctly
The original code cannot convert "" in filter expression to
a token correctly. The following command line exposes the
bug this change fixes:

  # ./lsfd  -o+ENDPOINTS  -Q '(TYPE == "")'
  zsh: IOT instruction  sudo ./lsfd -Q '(TYPE == "")'

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2022-04-05 04:39:24 +09:00
Masatake YAMATO
97a977cb85 lsfd: (filter): fix a codeing style of if/else
This is only cosmetic change.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2022-04-05 04:34:43 +09:00
наб
a938f9f0c2 libmount: fix typos 2022-04-01 10:21:41 +02:00
Karel Zak
39679ea0ce lsfd: use new libsmartcols functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-02-11 12:28:13 +01:00
Karel Zak
acc47228f0 lsfd: fix copy & past error [coverity scan]
1235            if (right->type != NODE_NUM) {
1236                    snprintf(parser->errmsg, ERRMSG_LEN,
1237                             _("error: unexpected right operand type %s for: %s"),
>>>     CID 374358:  Incorrect expression  (COPY_PASTE_ERROR)
>>>     "left" in "left->type" looks like a copy-paste error.
1238                             NODE_CLASS(left)->name,
1239                             op2_class->name);
1240                    return false;
1241            }

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-11-29 13:46:17 +01:00
Karel Zak
f22ef0fefd lsfd: fix use-after-free and resource leak [coverity scan]
>>>     CID 374363:  Memory - illegal accesses  (USE_AFTER_FREE)
>>>     Dereferencing freed pointer "t".
764                             snprintf(parser->errmsg, ERRMSG_LEN,
765                                      _("error: unsupported column data type: %d, column: %s"),
766                                      jtype, t->val.str);

856             default:
857                     warnx("unexpected token type: %d", t->type);
>>>     CID 374360:  Resource leaks  (RESOURCE_LEAK)
>>>     Variable "t" going out of scope leaks the storage it points to.
858                     return NULL;

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-11-29 13:41:36 +01:00
Masatake YAMATO
adb7db4c63 lsfd: (filter) make some data structures its source file local
Unintentionally they were extern'ed.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-11-18 23:52:46 +09:00
Masatake YAMATO
e095a2d6fb lsfd: (filter) accept % char as a part of column name
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-21 21:06:39 +09:00
Masatake YAMATO
cdc778cf2c lsfd: (filter) fix a memory leak
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-21 21:06:39 +09:00
Masatake YAMATO
024ca9ba70 lsfd: declare local variables at the beginning of block
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-21 21:05:35 +09:00
Masatake YAMATO
f439236f2c lsfd: (filter) implement !~, an operator for regex unmatching
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-11 04:00:12 +09:00
Masatake YAMATO
abaf378c0f lsfd: (filter) implement =~, an operator for regex matching
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-08 15:53:57 +09:00
Masatake YAMATO
23a4b2b22d lsfd: (filter) make error messages in check_type methods
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-08 15:53:57 +09:00
Masatake YAMATO
87ffe87ffc lsfd: (filter) give a name to a constant
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-08 15:53:57 +09:00
Masatake YAMATO
d0238cb735 lsfd: (filter) whitespace cleanup
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-08 15:53:55 +09:00
Masatake YAMATO
ae6ccf51e8 lsfd: wrap code for debugging with #ifdef DEBUG/#endif
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-06 11:01:54 +02:00
Masatake YAMATO
eb83898ac1 lsfd: convert lines introducing local variable to a block with {...}
The following code causing an error on test run on GitHub Action:

  case FOO:
      type localvar;

This change converts above code to:

  case FOO: {
      type localvar;
  }

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-06 11:01:54 +02:00
Masatake YAMATO
ef70cdd96d lsfd: change the license of the filtering engine to LGPL
This change is for moving the filtering engine to libsmartcols in the
future.

In addition to the change, I made myself a copyright holder of the
code.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-06 11:01:54 +02:00
Karel Zak
f8fa2c2a76 lsfd: use new scols_line_get_column_data()
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-10-06 11:01:54 +02:00
Masatake YAMATO
846b4cbee2 lsfd: add filter engine
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2021-10-06 11:01:54 +02:00