From be5631dff1f4f28636ba1b88e9d17034fe4551d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Sat, 31 Dec 2022 18:09:39 +0100 Subject: fixed bdecoding strncpy->memcpy +etc --- utils/bencoding.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'utils') diff --git a/utils/bencoding.c b/utils/bencoding.c index ec5909d..ad6ded0 100644 --- a/utils/bencoding.c +++ b/utils/bencoding.c @@ -8,7 +8,7 @@ #define S0(x) (x ? x : "") int main (int argc, char ** argv) { if (argc < 1+1) - error_at_line(1, 0, __FILE__, __LINE__, "%s encode < json || %s decode < bencoding || %s path path/to/obj < bencoding || %s foreach < bencoding || %s val value < bencoding (should output null or value as JSON string if found in array) || %s insert bencoding [replace] < bencoding || %s compare bencoding < bencoding || %s encode < bencoding", S0(argv[0]), S0(argv[0]), S0(argv[0]), S0(argv[0]), S0(argv[0]), S0(argv[0]), S0(argv[0]), S0(argv[0])); + error_at_line(1, 0, __FILE__, __LINE__, "%s encode < json || %s decode < bencoding || %s path path/to/obj < bencoding || %s foreach < bencoding || %s val value < bencoding (should output null or value as JSON string if found in array) || %s insert bencoding [replace] < bencoding || %s compare bencoding < bencoding", S0(argv[0]), S0(argv[0]), S0(argv[0]), S0(argv[0]), S0(argv[0]), S0(argv[0]), S0(argv[0])); if (argv[1][0] == 'p' && argc != 1+2) error_at_line(1, 0, __FILE__, __LINE__, "set path!"); int size = 2048; @@ -29,7 +29,7 @@ int main (int argc, char ** argv) { *end = '\0'; puts(out); if (end - out != len) - error_at_line(4, 0, __FILE__, __LINE__, "b2json wrote %ld instead of %d bytes.", end-out, len); + error_at_line(4, 0, __FILE__, __LINE__, "b2json wrote %td instead of %d bytes.", end-out, len); fprintf(stderr, "len: %d\n", len); } if (argv[1][0] == 'p') { @@ -39,7 +39,7 @@ int main (int argc, char ** argv) { *end = '\0'; puts(out); if (end - out != len) - error_at_line(4, 0, __FILE__, __LINE__, "b2json wrote %ld instead of %d bytes.", end-out, len); + error_at_line(4, 0, __FILE__, __LINE__, "b2json wrote %td instead of %d bytes.", end-out, len); fprintf(stderr, "len: %d\n", len); } if (argv[1][0] == 'v') { @@ -49,24 +49,24 @@ int main (int argc, char ** argv) { *end = '\0'; puts(out); if (end - out != len) - error_at_line(4, 0, __FILE__, __LINE__, "b2json wrote %ld instead of %d bytes.", end-out, len); + error_at_line(4, 0, __FILE__, __LINE__, "b2json wrote %td instead of %d bytes.", end-out, len); fprintf(stderr, "len: %d\n", len); } if (argv[1][0] == 'f') { - bforeach (value, bencoding) { + bforeach (bencoding, value) { len = b2json_length(value->key); char out[len+1]; char * end = b2json(out, value->key); *end = '\0'; if (end - out != len) - error_at_line(4, 0, __FILE__, __LINE__, "b2json wrote %ld instead of %d bytes.", end-out, len); + error_at_line(4, 0, __FILE__, __LINE__, "b2json wrote %td instead of %d bytes.", end-out, len); printf("key(%d): %s\n", len, out); len = b2json_length(value); char out2[len+1]; end = b2json(out2, value); *end = '\0'; if (end - out2 != len) - error_at_line(4, 0, __FILE__, __LINE__, "b2json wrote %ld instead of %d bytes.", end-out2, len); + error_at_line(4, 0, __FILE__, __LINE__, "b2json wrote %td instead of %d bytes.", end-out2, len); printf("value(%d): %s\n", len, out2); } } @@ -85,7 +85,7 @@ int main (int argc, char ** argv) { *end = '\0'; puts(out); if (end - out != len) - error_at_line(4, 0, __FILE__, __LINE__, "b2json wrote %ld instead of %d bytes.", end-out, len); + error_at_line(4, 0, __FILE__, __LINE__, "b2json wrote %td instead of %d bytes.", end-out, len); fprintf(stderr, "len: %d\n", len); } if (argv[1][0] == 'c') { -- cgit v1.2.3