Skip to content

Commit 78bccf8

Browse files
author
Matthäus Wininger
committed
Improve code clarity and remove TODOs (issues TBA)
1 parent 0bf16cc commit 78bccf8

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

README.md

-10
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,6 @@ Options:
153153

154154
![zps -n](assets/demo-no-color.gif)
155155

156-
## TODO(s)
157-
158-
- Check Korean translation for mistranslations introduced in new release.
159-
- Maybe extend `cmdline`/`COMMAND` output to extend to the maximum line length,
160-
although this would still lead to varying results if one were to look for
161-
a specific string in the "interactive"/non-piped `zps` output manually
162-
compared to piping `stdout` to `grep`, as the maximum line length would
163-
not have the same limit. Thus, it might actually be desirable to actually
164-
limit the lengths in any case.
165-
166156
## License
167157

168158
GNU General Public License v3.0 only ([GPL-3.0-only](https://www.gnu.org/licenses/gpl.txt))

README_KO.md

-10
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,6 @@ docker run zps
147147

148148
![zps -n](assets/demo-no-color.gif)
149149

150-
## TODO(s)
151-
152-
- Check Korean translation for mistranslations introduced in new release.
153-
- Maybe extend `cmdline`/`COMMAND` output to extend to the maximum line length,
154-
although this would still lead to varying results if one were to look for
155-
a specific string in the "interactive"/non-piped `zps` output manually
156-
compared to piping `stdout` to `grep`, as the maximum line length would
157-
not have the same limit. Thus, it might actually be desirable to actually
158-
limit the lengths in any case.
159-
160150
## License
161151

162152
GNU General Public License v3.0 only ([GPL-3.0-only](https://www.gnu.org/licenses/gpl.txt))

src/zps.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535

3636
#include "zps.h"
3737

38+
#ifndef PATH_MAX
39+
#define PATH_MAX MAX_BUF_SIZE
40+
#endif
41+
42+
/* Array used for lookup of common signals' abbreviations */
3843
static const char *const abbrevs[NSIG] = {
3944
[SIGHUP] = "HUP", [SIGINT] = "INT", [SIGQUIT] = "QUIT",
4045
[SIGILL] = "ILL", [SIGTRAP] = "TRAP", [SIGABRT] = "ABRT",
@@ -430,8 +435,12 @@ static ssize_t read_file(char *buf, size_t bufsiz, const char *format, ...)
430435
assert(format);
431436

432437
va_start(vargs, format);
433-
vsnprintf(path, sizeof(path), format, vargs);
438+
int num_required = vsnprintf(path, sizeof(path), format, vargs);
434439
va_end(vargs);
440+
/* Check for errors or truncation */
441+
if (num_required < 0 || (size_t)num_required >= sizeof(path)) {
442+
return -1;
443+
}
435444

436445
const int fd = open(path, O_RDONLY);
437446
if (fd == -1) {

0 commit comments

Comments
 (0)