On some systems dirname uses a static string for its return value, so
we were calling mkdirs recursively on a string that was continuosly changing.
A check was also added after the `snprintf` to make sure there's no
information loss since there is no limit to the length of the string
returned by `get_data_pathfmt`.
Closes#48.
In file included from .../include/string.h:495,
from src/gmnlm.c:11:
In function ‘strncpy’,
inlined from ‘do_prompts’ at src/gmnlm.c:627:3:
...glibc-2.31-dev/include/bits/string_fortified.h:106:10:
error: ‘__builtin_strncpy’ specified bound 1024 equals
destination size [-Werror=stringop-truncation]
return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
inlined from ‘do_prompts’ at src/gmnlm.c:612:3:
...glibc-2.31-dev/include/bits/string_fortified.h:106:10:
error: ‘__builtin_strncpy’ specified bound 1024 equals destination size
[-Werror=stringop-truncation]
return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: William Casarin <jb55@jb55.com>
dirname has two main problems:
1. It could change in place the string that is passed to it.
2. It uses a static string for its return value, so one should copy it
somewhere else as soon as possible to avoid subsequent calls to
dirname to corrupt his data (see #48).
We avoid 1. passing a copy of `path` to dirname and 2. copying it's
return value into `dname`.
My compiler barks about this unitialized variable:
CC src/gmnlm.o
src/gmnlm.c:629:7: error: variable 'result' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (res != GEMINI_OK) {
^~~~~~~~~~~~~~~~
src/gmnlm.c:673:9: note: uninitialized use occurs here
return result;
^~~~~~
src/gmnlm.c:629:3: note: remove the 'if' if its condition is always false
if (res != GEMINI_OK) {
^~~~~~~~~~~~~~~~~~~~~~~
src/gmnlm.c:482:2: note: variable 'result' is declared here
enum prompt_result result;
^
1 error generated.
make: *** [src/gmnlm.o] Error 1
This reverts commit 963700d8d6.
Let's make the p command consistent with the others and tell users who
want to navigate to a relative URL unambiguosly to use ./page
The rest of gmni's stuff will remain in ~/.local/share/gmni, but in
order to establish a common location and format for the TOFU file
between Gemini implementations, a more general path is required.
The return value of set_url() was not checked, meaning that when it
failed, gmnlm continued anyway, causing an assertion to fail and
subsequentially resulting in a segfault.
This adds a command, 'H', to view all the URLs in the page history. It
first prints backward URLs, then the current URL (marked with an
asterisk), followed by forward URLs.