Hi Alex, John,

On Thu, Oct 30, 2025 at 12:05:51PM +0000, [email protected] wrote:
> Hi,
> 
> I saw this issue on Reddit today pertaining to the Gopher plugin not
> working correctly on OpenBSD. It includes a fix (I haven't tested it):
> 
> https://eddrit.com/r/openbsd/comments/1oj3ljg/dillo_gopher_plugin_issue_workaround_request/

Thanks, I saw it as well. Nice frontend btw.

> Date: Thu, 30 Oct 2025 11:10:21 -0400
> From: John McCue <[email protected]>
> To: [email protected]
> Cc: [email protected]
> Subject: Re: Dillo gopher plugin on OpenBSD issue
> 
> 
> [...]
> 
> Somehow I missed it seeing there was a list.  I found another
> issues with the gopher plugin on OpenBSD.
> 
> The issue I am testing is with dpi.c.  On OpenBSD, it has to
> do with how clang works on OpenBSD.  The diffs are below.

I can reproduce many issues on Linux with `CC=clang make`. I'm getting a 
few more warnings that should be easy to solve.

> So far, with the changes to io.c and dpi.c, the plugin
> works fine on both OpenBSD and NetBSD.
> 
> diff --git a/io.c b/io.c
> index 615f346..a10a0b3 100644
> --- a/io.c
> +++ b/io.c
> @@ -1,3 +1,4 @@
> +#include <sys/param.h>
>   #include <string.h>
>   #include <errno.h>
>   #include <unistd.h>
> @@ -8,6 +9,12 @@
>   #include <netdb.h>
>   #include <netinet/in.h>
>   
> +#ifdef OpenBSD

I don't think we need to handle OpenBSD differently, but instead make 
the code portable by targeting C and POSIX standards.

> +#include <sys/socket.h>

This is always needed as we use socket(), but it should not be needed
here as it would be included via <netinet/in.h>, from netinet_in.h(0P):

> Inclusion of the <netinet/in.h> header may also make visible all
> symbols from <inttypes.h> and <sys/socket.h>

Not sure if OpenBSD follows this, otherwise can simply include it
unconditionally.

> +#include <net/if.h>
> +#include <net/route.h>

Needed?

> +#endif
> +

Building with:

  % make CC=clang CFLAGS="-std=c11 -Wall -pedantic"

Already reveals many problems. We can probably lower the C standard to 
C99.

I don't have a machine with OpenBSD at hand, can you test if the build
succeeds using the current master code in OpenBSD with these CFLAGS? It
does on Linux:

  % git clone https://git.dillo-browser.org/plugins/gopher && cd gopher
  % make CC=clang CFLAGS="-Wall -std=c99 -D_POSIX_C_SOURCE=200112L"

There are many warnings that should be fixed (as below), but the
current includes should work otherwise. If not, does adding the extra

+ #include <sys/socket.h>

line solves it?

>   #include "io.h"
>   
>   int read_all(int fd, unsigned char *buf, size_t len) {
> 
> 
> diff --git a/dpi.c b/dpi.c
> index 7b38800..52547f8 100644
> --- a/dpi.c
> +++ b/dpi.c
> @@ -7,7 +7,7 @@
>   #include "io.h"
>   
>   static void check_auth() {
> -     char buf[30];
> +     char buf[31];
>       int rc;
>       char key[4], local_key[4];
>       char keys[128];
> @@ -16,16 +16,16 @@ static void check_auth() {
>       rc = read_all(STDIN_FILENO, buf, 29);
>       if (rc < 0) err(1, "read auth");
>       buf[30] = '\0';
> -     rc = sscanf(buf, "<cmd='auth' msg='%4x' '>", key);
> +     rc = sscanf(buf, "<cmd='auth' msg='%4x' '>", (unsigned int *)
> key); if (rc < 0) err(1, "auth: %.*s", 29, buf);

The patch is badly mangled, better use `git send-patch` or attach it as 
a file.

>       if (rc < 1) errx(1, "auth: %.*s", 29, buf);
>       home = getenv("HOME");
>       if (!home) home = ".";
>       sz = read_file(keys, sizeof(keys),
> "%s/.dillo/dpid_comm_keys", home); if (sz < 0) err(1, "read dillo comm
> keys");
> -     rc = sscanf(keys, "%*d %4x' '>", local_key);
> -     if (rc < 0) err(1, "comm key: %.*s", sz, keys);
> -     if (rc < 1) errx(1, "comm key: %.*s", sz, keys);
> +     rc = sscanf(keys, "%*d %4x' '>", (unsigned int *) local_key);
> +     if (rc < 0) err(1, "comm key: %.*s", (int) sz, keys);
> +     if (rc < 1) errx(1, "comm key: %.*s", (int) sz, keys);
>       if (memcmp(key, local_key, 4)) errx(1, "wrong dillo key");
>   }
>   
> @@ -38,7 +38,7 @@ static void get_url(char *url_buf, size_t url_len) {
>       rc = read_all(STDIN_FILENO, buf, sizeof(buf));
>       if (rc < 0) err(1, "read open_url");
>       if (strncmp(buf, "<cmd='open_url' url='", 21)) {
> -             err(1, "bad open_url cmd: %.*s", sizeof(buf), buf);
> +             err(1, "bad open_url cmd: %.*s", (int) sizeof(buf),
> buf); }
>       len = url_len;
>       rc = read_some(STDIN_FILENO, url_buf, &len);
> @@ -48,7 +48,7 @@ static void get_url(char *url_buf, size_t url_len) {
>               if (url_buf[i] == '\'' && url_buf[i+1] == ' ') break;
>       }
>       if (i > len-3 || strncmp(url_buf + i, "' '>", 4)) {
> -             err(1, "bad url end: %.*s", len, url_buf);
> +             err(1, "bad url end: %.*s", (int) len, url_buf);
>       }
>       url_buf[i] = '\0';
>   }
> 

Thanks!,
Rodrigo.
_______________________________________________
Dillo-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to