nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1diff --git a/commands.c b/commands.c
2index a28e6da..0f76ac7 100644
3--- a/commands.c
4+++ b/commands.c
5@@ -20,6 +20,7 @@
6 #include <stdlib.h>
7 #include <string.h>
8 #include <unistd.h>
9+#include <limits.h>
10 #include <errno.h>
11 #include "commands.h"
12 #include "platform.h"
13@@ -150,7 +151,13 @@ build_symlink_name(const char *path_to_bin, const struct cmd_info *cmd)
14 {
15 static char link_name[FILENAME_MAX];
16
17- snprintf(link_name, FILENAME_MAX, "%s/%s", path_to_bin, cmd->name);
18+ int result = snprintf(link_name, PATH_MAX, "%s/%s", path_to_bin, cmd->name);
19+
20+ if (result >= PATH_MAX) {
21+ link_name[PATH_MAX - 1] = '\0';
22+ } else if (result < 0) {
23+ link_name[0] = '\0';
24+ }
25
26 return link_name;
27 }