Skip to content

Force Proxy to any Windows/MacOS/Linux Application TCP and UDP traffic

fix(linux): tighten save-time config mode and platform json key match

Rhino4c28b084c268
diff --git a/Linux/gui/gui_config.c b/Linux/gui/gui_config.c
index 8e9c05c..46c9571 100644
--- a/Linux/gui/gui_config.c
+++ b/Linux/gui/gui_config.c
@@ -21,6 +21,10 @@ void save_config() {
printf("failed to save config to %s\n", CONFIG_PATH);
return;
}
+ // mode on open only hits create; tighten existing 0644 installs too
+ if (fchmod(cfg_fd, 0600) != 0) {
+ perror("chmod config file failed");
+ }
FILE *f = fdopen(cfg_fd, "w");
if (!f) {
close(cfg_fd);
diff --git a/Linux/gui/main.c b/Linux/gui/main.c
index cbc2873..388622e 100644
--- a/Linux/gui/main.c
+++ b/Linux/gui/main.c
@@ -37,15 +37,27 @@ static void on_dns_proxy_toggled(GtkCheckMenuItem *item, gpointer data) {
// same feed as windows/mac: https://download.interceptsuite.com/proxybridge.json
#define UPD_FEED_URL "https://download.interceptsuite.com/proxybridge.json"
+// match "linux": { ... } as a key, not a random "linux" string value
static char *extract_platform_block(const char *json, const char *platform) {
char needle[64];
snprintf(needle, sizeof(needle), "\"%s\"", platform);
- char *p = strstr(json, needle);
- if (!p) return NULL;
- char *brace = strchr(p, '{');
+ size_t nlen = strlen(needle);
+ const char *p = json;
+ const char *key = NULL;
+ while ((p = strstr(p, needle)) != NULL) {
+ const char *after = p + nlen;
+ while (*after == ' ' || *after == '\t' || *after == '\n' || *after == '\r') after++;
+ if (*after == ':') {
+ key = p;
+ break;
+ }
+ p += nlen;
+ }
+ if (!key) return NULL;
+ const char *brace = strchr(key, '{');
if (!brace) return NULL;
int depth = 0;
- for (char *q = brace; *q; q++) {
+ for (const char *q = brace; *q; q++) {
if (*q == '{') depth++;
else if (*q == '}') {
depth--;