summaryrefslogtreecommitdiff
path: root/other/fun
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-07-17 01:18:04 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-07-22 02:34:30 +0000
commitf627a26a7b1c3619ba66f84b87092ff8ba7a95b6 (patch)
treec72c950fab473dc9bec4b5329d251b790e55443d /other/fun
parent7245ac11ef9be2420c8356c12acc79f93ea211bb (diff)
Run Clang global static analysis on Travis.
This uses a single .cc file containing almost all the code in the repository to perform whole program analysis.
Diffstat (limited to 'other/fun')
-rw-r--r--other/fun/cracker.c2
-rw-r--r--other/fun/sign.c15
-rw-r--r--other/fun/strkey.c2
3 files changed, 9 insertions, 10 deletions
diff --git a/other/fun/cracker.c b/other/fun/cracker.c
index 502a8af0..fd9564f6 100644
--- a/other/fun/cracker.c
+++ b/other/fun/cracker.c
@@ -20,7 +20,7 @@
20#include "../../testing/misc_tools.h" 20#include "../../testing/misc_tools.h"
21#include "../../toxcore/ccompat.h" 21#include "../../toxcore/ccompat.h"
22 22
23void print_key(uint8_t *client_id) 23static void print_key(uint8_t *client_id)
24{ 24{
25 uint32_t j; 25 uint32_t j;
26 26
diff --git a/other/fun/sign.c b/other/fun/sign.c
index 007d19a0..547af311 100644
--- a/other/fun/sign.c
+++ b/other/fun/sign.c
@@ -21,7 +21,7 @@
21#include "../../testing/misc_tools.h" // hex_string_to_bin 21#include "../../testing/misc_tools.h" // hex_string_to_bin
22#include "../../toxcore/ccompat.h" 22#include "../../toxcore/ccompat.h"
23 23
24int load_file(char *filename, char **result) 24static int load_file(char *filename, unsigned char **result)
25{ 25{
26 int size = 0; 26 int size = 0;
27 FILE *f = fopen(filename, "rb"); 27 FILE *f = fopen(filename, "rb");
@@ -34,7 +34,7 @@ int load_file(char *filename, char **result)
34 fseek(f, 0, SEEK_END); 34 fseek(f, 0, SEEK_END);
35 size = ftell(f); 35 size = ftell(f);
36 fseek(f, 0, SEEK_SET); 36 fseek(f, 0, SEEK_SET);
37 *result = (char *)malloc(size + 1); 37 *result = (unsigned char *)malloc(size + 1);
38 38
39 if (size != fread(*result, sizeof(char), size, f)) { 39 if (size != fread(*result, sizeof(char), size, f)) {
40 free(*result); 40 free(*result);
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
72 72
73 if (argc == 5 && argv[1][0] == 's') { 73 if (argc == 5 && argv[1][0] == 's') {
74 unsigned char *secret_key = hex_string_to_bin(argv[2]); 74 unsigned char *secret_key = hex_string_to_bin(argv[2]);
75 char *data; 75 unsigned char *data;
76 int size = load_file(argv[3], &data); 76 int size = load_file(argv[3], &data);
77 77
78 if (size < 0) { 78 if (size < 0) {
@@ -80,7 +80,7 @@ int main(int argc, char *argv[])
80 } 80 }
81 81
82 unsigned long long smlen; 82 unsigned long long smlen;
83 char *sm = malloc(size + crypto_sign_ed25519_BYTES * 2); 83 unsigned char *sm = (unsigned char *)malloc(size + crypto_sign_ed25519_BYTES * 2);
84 crypto_sign_ed25519(sm, &smlen, data, size, secret_key); 84 crypto_sign_ed25519(sm, &smlen, data, size, secret_key);
85 free(secret_key); 85 free(secret_key);
86 86
@@ -106,19 +106,18 @@ int main(int argc, char *argv[])
106 106
107 if (argc == 4 && argv[1][0] == 'c') { 107 if (argc == 4 && argv[1][0] == 'c') {
108 unsigned char *public_key = hex_string_to_bin(argv[2]); 108 unsigned char *public_key = hex_string_to_bin(argv[2]);
109 char *data; 109 unsigned char *data;
110 int size = load_file(argv[3], &data); 110 int size = load_file(argv[3], &data);
111 111
112 if (size < 0) { 112 if (size < 0) {
113 goto fail; 113 goto fail;
114 } 114 }
115 115
116 char *signe = malloc(size + crypto_sign_ed25519_BYTES); 116 unsigned char *signe = (unsigned char *)malloc(size + crypto_sign_ed25519_BYTES);
117 memcpy(signe, data + size - crypto_sign_ed25519_BYTES, 117 memcpy(signe, data + size - crypto_sign_ed25519_BYTES,
118 crypto_sign_ed25519_BYTES); // Move signature from end to beginning of file. 118 crypto_sign_ed25519_BYTES); // Move signature from end to beginning of file.
119 memcpy(signe + crypto_sign_ed25519_BYTES, data, size - crypto_sign_ed25519_BYTES); 119 memcpy(signe + crypto_sign_ed25519_BYTES, data, size - crypto_sign_ed25519_BYTES);
120 unsigned long long smlen; 120 unsigned char *m = (unsigned char *)malloc(size);
121 char *m = malloc(size);
122 unsigned long long mlen; 121 unsigned long long mlen;
123 122
124 if (crypto_sign_ed25519_open(m, &mlen, signe, size, public_key) == -1) { 123 if (crypto_sign_ed25519_open(m, &mlen, signe, size, public_key) == -1) {
diff --git a/other/fun/strkey.c b/other/fun/strkey.c
index ef54a404..d769318a 100644
--- a/other/fun/strkey.c
+++ b/other/fun/strkey.c
@@ -43,7 +43,7 @@
43 43
44#define PRINT_TRIES_COUNT 44#define PRINT_TRIES_COUNT
45 45
46void print_key(unsigned char *key) 46static void print_key(unsigned char *key)
47{ 47{
48 size_t i; 48 size_t i;
49 49