MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / security_read_file

Function security_read_file

tests/test_security.c:29–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27#include <sys/stat.h>
28
29static char *security_read_file(const char *path) {
30 FILE *file = fopen(path, "rb");
31 if (!file || fseek(file, 0, SEEK_END) != 0) {
32 if (file)
33 fclose(file);
34 return NULL;
35 }
36 long size = ftell(file);
37 if (size < 0 || fseek(file, 0, SEEK_SET) != 0) {
38 fclose(file);
39 return NULL;
40 }
41 char *content = (char *)malloc((size_t)size + 1U);
42 if (!content || fread(content, 1U, (size_t)size, file) != (size_t)size) {
43 free(content);
44 fclose(file);
45 return NULL;
46 }
47 content[size] = '\0';
48 fclose(file);
49 return content;
50}
51
52static void security_normalize_crlf(char *content) {
53 if (!content) {

Callers 2

test_security.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected