Skip to content

Commit b7fa018

Browse files
committed
fix(security) & init(nix): use strl instead of strn in functions. Introduce nix-compilation support with .envrc and nix-shell
1 parent 7df63cd commit b7fa018

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use nix

shell.nix

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{ pkgs ? import <nixpkgs> {}}:
2+
3+
pkgs.mkShell {
4+
allowUnfree = true;
5+
name = "hamon!";
6+
packages = with pkgs; [
7+
zsh
8+
clang-tools
9+
clang
10+
mold
11+
];
12+
shellHook = ''
13+
'';
14+
}

src/hamon/cli.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <stdio.h>
21
#define COLORS
32
#define GRAPHICS
43

src/hamon/config.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ int gen_default_config(void) {
130130
return 1;
131131
}
132132

133-
strncpy(config_buffer, default_config, config_buffer_size);
133+
strlcpy(config_buffer, default_config, config_buffer_size);
134134

135135
#if _WIN32
136136
env_size = strlen(getenv("APPDATA"));

src/hamon/escape.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ char *assemble(char *codes[], int codesc) {
1515
snprintf(buffer, sizeof(BASE), BASE);
1616

1717
for (int code_index = 0; code_index < codesc; code_index++) {
18-
strncat(buffer, codes[code_index], sizeof(codes[code_index]));
18+
strlcat(buffer, codes[code_index], sizeof(codes[code_index]));
1919
if (code_index != (codesc - 1)) {
20-
strncat(buffer, ";", 1);
20+
strlcat(buffer, ";", 1);
2121
}
2222
}
2323

24-
strncat(buffer, END, 1);
24+
strlcat(buffer, END, 1);
2525
return buffer;
2626
}
2727

src/hamon/file.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
#include <stdio.h>
21
#define COLORS
32

4-
#include "headers/escape.h"
53
#include "headers/file.h"
4+
#include "headers/escape.h"
65

76
int write_file(const char *filename, const char *content, const size_t size) {
87
FILE *file = fopen(filename, "w");

0 commit comments

Comments
 (0)