From 20d321d9bdcc3b3e1d7274f1b06a7402d48ad7f0 Mon Sep 17 00:00:00 2001 From: benryves Date: Fri, 26 Apr 2024 00:44:37 +0100 Subject: [PATCH 1/8] Removed unused arpa/inet.h #includes to allow building on Windows. --- src/exword.c | 1 - src/obex.c | 1 - 2 files changed, 2 deletions(-) diff --git a/src/exword.c b/src/exword.c index 63a8563..06e19a9 100644 --- a/src/exword.c +++ b/src/exword.c @@ -19,7 +19,6 @@ * */ -#include #include #include #include diff --git a/src/obex.c b/src/obex.c index a5c4922..83ddf18 100644 --- a/src/obex.c +++ b/src/obex.c @@ -24,7 +24,6 @@ * */ -#include #include #include From 2ef93fd6589b973883835a1eedeaa3cca3862578 Mon Sep 17 00:00:00 2001 From: benryves Date: Fri, 26 Apr 2024 00:47:49 +0100 Subject: [PATCH 2/8] Use offsetof() to avoid pointer casting warnings. --- src/list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/list.h b/src/list.h index 3a76885..6a62fbd 100644 --- a/src/list.h +++ b/src/list.h @@ -187,7 +187,7 @@ static inline void list_splice_init(struct list_head *list, * @member: the name of the list_struct within the struct. */ #define list_entry(ptr, type, member) \ - ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) + ((type *)((void *)(ptr)-offsetof(type, member))) /** * list_for_each - iterate over a list From 97cfe52f09e783c4af7e81188a779ec3af479129 Mon Sep 17 00:00:00 2001 From: benryves Date: Fri, 26 Apr 2024 00:49:40 +0100 Subject: [PATCH 3/8] Included missing header to avoid warning when building on Windows. --- src/util.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util.h b/src/util.h index 6c8c61c..03fbc51 100644 --- a/src/util.h +++ b/src/util.h @@ -23,6 +23,7 @@ #define _UTIL_H #if defined(__MINGW32__) +# include # define mkdir(path, mode) _mkdir(path) # define PATH_SEP "\\" #else From da281c587e537726720e35edcd8ed69712835c82 Mon Sep 17 00:00:00 2001 From: benryves Date: Fri, 26 Apr 2024 01:03:09 +0100 Subject: [PATCH 4/8] Corrected buffer size calculation from strlen(str + 1) to strlen(str) + 1. Previous code would allocate buffers two bytes too small and crash with heap error after freeing. --- src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 40ff7c5..21984a1 100644 --- a/src/main.c +++ b/src/main.c @@ -507,7 +507,7 @@ void content(struct state *s) if (peek_arg(&(s->cmd_list)) == NULL) { printf("No sub-function specified.\n"); } else { - subfunc = xmalloc(strlen(peek_arg(&(s->cmd_list)) + 1)); + subfunc = xmalloc(strlen(peek_arg(&(s->cmd_list))) + 1); strcpy(subfunc, peek_arg(&(s->cmd_list))); dequeue_arg(&(s->cmd_list)); if (strcmp(subfunc, "list") == 0) { @@ -541,7 +541,7 @@ void content(struct state *s) printf("No username specified.\n"); } } else { - user = xmalloc(strlen(peek_arg(&(s->cmd_list)) + 1)); + user = xmalloc(strlen(peek_arg(&(s->cmd_list))) + 1); strcpy(user, peek_arg(&(s->cmd_list))); dequeue_arg(&(s->cmd_list)); } From cf1815861552cf56cbeff32a17397a7c0c009568 Mon Sep 17 00:00:00 2001 From: benryves Date: Sat, 27 Apr 2024 18:21:41 +0100 Subject: [PATCH 5/8] Included stddef.h to ensure offsetof macro is available. --- src/list.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/list.h b/src/list.h index 6a62fbd..76dffb7 100644 --- a/src/list.h +++ b/src/list.h @@ -1,6 +1,8 @@ #ifndef __LIST_H #define __LIST_H +#include + /* This file is from Linux Kernel (include/linux/list.h) * and modified by simply removing hardware prefetching of list items. * Here by copyright, credits attributed to wherever they belong. From c698bfa46ed1319722a0df25f561131aece882b7 Mon Sep 17 00:00:00 2001 From: benryves Date: Sat, 27 Apr 2024 18:28:04 +0100 Subject: [PATCH 6/8] Restored includes with for Windows. --- src/exword.c | 6 ++++++ src/obex.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/exword.c b/src/exword.c index 06e19a9..10b295a 100644 --- a/src/exword.c +++ b/src/exword.c @@ -19,6 +19,12 @@ * */ +#if defined(__MINGW32__) +# include +#else +# include +#endif + #include #include #include diff --git a/src/obex.c b/src/obex.c index 83ddf18..3f99b60 100644 --- a/src/obex.c +++ b/src/obex.c @@ -24,6 +24,12 @@ * */ +#if defined(__MINGW32__) +# include +#else +# include +#endif + #include #include From 8d050b72c694bd3178c2cc39d2642212ce1cab25 Mon Sep 17 00:00:00 2001 From: benryves Date: Thu, 23 May 2024 03:42:13 +0100 Subject: [PATCH 7/8] Added XD-SW6500 to list of models. --- models.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/models.txt b/models.txt index 3e7e7c9..83949da 100644 --- a/models.txt +++ b/models.txt @@ -10,6 +10,7 @@ Dataplus 3 EW-H6000 gy131,ON,0101 gy331 07cf:6101 Dataplus 3 XD-SW4800 gy131,ON,0101 gy350 07cf:6101 Dataplus 3 XD-SW9400 gy131,ON,0101 gy352 07cf:6101 Dataplus 3 XD-SW6400 gy131,ON,0101 gy355 07cf:6101 +Dataplus 3 XD-SW6500 gy131,ON,0200 gy356 07cf:6101 Dataplus 3 XD-GW9600 gy131,ON,0101 gy392 07cf:6101 Dataplus 4 EV-SP2900 gy131,ON,0100 gy808 07cf:6101 Dataplus 4 EV-SP3900 gy131,ON,0100 gy809 07cf:6101 From 400fc0e301d91a60661a839ac713ac0693334c69 Mon Sep 17 00:00:00 2001 From: benryves Date: Sat, 25 May 2024 03:25:46 +0100 Subject: [PATCH 8/8] Fixed "dict auth" with no username. Attempt to retrieve username from diary's user.inf failed as returned buffer may not be a NUL- or whitespace-terminated string and sscanf() would read junk past the end of the username. --- src/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 21984a1..56d17f2 100644 --- a/src/main.c +++ b/src/main.c @@ -535,7 +535,14 @@ void content(struct state *s) int rsp = exword_get_file(s->device, "user.inf", &buffer, &len); if (rsp == EXWORD_SUCCESS) { user = xmalloc(len+1); - sscanf(buffer, "%s\n", user); + for (int i = 0; i < len; i++) { + user[i + 1] = 0; + if (buffer[i] > ' ') { + user[i] = buffer[i]; + } else { + break; + } + } free(buffer); } else { printf("No username specified.\n");