1
0
Fork 0
mirror of https://git.sr.ht/~sircmpwn/gmni synced 2024-06-11 10:26:43 +02:00
Commit Graph

96 Commits

Author SHA1 Message Date
Giuseppe Lumia cb63b8ddf0 Fix bug on mkdirs calls
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.
2020-11-17 10:00:53 -05:00
William Casarin ec88f4558c gmnlm: fix a few strncpy compile errors on gcc 9.3
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>
2020-11-17 09:30:56 -05:00
Giuseppe Lumia ab66dd2be9 Simplify posix_dirname logic
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`.
2020-11-17 09:30:56 -05:00
René Wagner 61af57e302 fix typo in PERMANENT FAILURE response 2020-11-06 10:05:43 -05:00
Jon Higgs 021d8f8fdf Improve the -j usage 2020-11-02 16:37:42 -05:00
Connor Kuehl c036a43801 Initialize result if res != GEMINI_OK
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
2020-10-31 19:00:28 -04:00
Joe Jenne 514cb37301 Fix const comparison Werror 2020-10-29 19:18:42 -04:00
Cédric Hannotier ac86b2f9fe Separate path and read buffers & use snprintf 2020-10-29 18:00:46 -04:00
Martijn Braam 122fb0a9fd Add static library for gmni 2020-10-24 13:41:07 -04:00
Drew DeVault 49c0c523c6 Fix possibly uninitialized variable 2020-10-24 11:05:17 -04:00
Eyal Sawady afab58cb64 Fix plaintext display 2020-10-21 10:15:24 -04:00
Eyal Sawady fc6d4a6f69 Add '|' to pipe page into an external program 2020-10-21 10:12:52 -04:00
Eyal Sawady fa78663748 Add 'd' to download page 2020-10-21 10:12:51 -04:00
Eyal Sawady 9ddd5c16da gmnlm: separate do_requests and display_response 2020-10-21 10:12:50 -04:00
Callum Brown 40308b8b0b gmnlm: Fix segfault when local file does not exist 2020-10-06 17:14:59 -04:00
Eyal Sawady 7619edcd11 Display last line when it doesn't end in a newline 2020-10-05 14:43:25 -04:00
Eyal Sawady a5eae7ea6b gmnlm: open_bookmarks: call mkdirs 2020-10-05 14:35:05 -04:00
Callum Brown 4b7fba261a Fix untrusted certificate message 2020-10-05 14:35:02 -04:00
Kevin Sangeelee 5d3ae7b7f5 Init known_hosts prior to fopen to avoid segfault. 2020-09-29 17:51:14 -04:00
Drew DeVault d84ee77e24 gmnlm: add -W option 2020-09-29 13:19:18 -04:00
Eyal Sawady 90995e834f gmnlm: show URL on untrusted cert 2020-09-29 11:26:28 -04:00
Drew DeVault dcc0484a8c Fix truncated hashes in known_hosts 2020-09-27 18:06:51 -04:00
Eyal Sawady 8c473eda5e Add 'i' to show media type parameters
Also don't show media type parameters in prompt
2020-09-27 15:47:46 -04:00
Drew DeVault 0b5c37d2e6 Further improvement to quote display 2020-09-27 13:32:55 -04:00
Drew DeVault 60496bae0c Improve display of preformatted & quotes 2020-09-27 13:25:40 -04:00
Drew DeVault b4fc0c0993 tofu.c: clarify reuse warning 2020-09-27 11:54:32 -04:00
Drew DeVault ce1ef1abde TOFU: verify hostnames 2020-09-27 11:40:49 -04:00
Drew DeVault 77de1bb2a8 Revert "gmnlm: p: require whitespace before link number"
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
2020-09-27 10:36:09 -04:00
Drew DeVault 4e61e26607 gmni: improve unknown trust message 2020-09-27 08:51:09 -04:00
Drew DeVault b298fadb21 Fix segfault on connection refused 2020-09-26 16:59:06 -04:00
Drew DeVault 0eaf9cc109 TOFU: use ~/.local/share/gemini/known_hosts
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.
2020-09-26 13:13:41 -04:00
Eyal Sawady 8bb1d81f53 gmnlm: handle CRLF line endings
Bare CRs are still printed as '.'.

Fixes https://todo.sr.ht/~sircmpwn/gmni/25
2020-09-24 15:33:57 -04:00
Eyal Sawady 963700d8d6 gmnlm: p: require whitespace before link number
In order to allow users to navigate to relative URLs starting with 'p'.
2020-09-24 14:57:15 -04:00
Eyal Sawady 5ad3f0aacc gmnlm: open bookmarks if started without URL 2020-09-24 14:57:14 -04:00
Eyal Sawady b050b9e467 gmnlm: return to previous page on empty input 2020-09-24 14:42:40 -04:00
Charles E. Lehner 689fb8b470 Close fd after freeing SSL
BIO_free_all may trigger write to close the SSL connection
2020-09-24 11:45:59 -04:00
Eyal Sawady 59d19b9894 Fix bookmark save/open
Fix a segfault on bookmark save and a memory leak on bookmark open.
2020-09-24 11:37:23 -04:00
Eyal Sawady f80e4037c2 Add 'r' to reload 2020-09-24 10:35:43 -04:00
Eyal Sawady 5fd43e8d02 gmni: use stdio to write body
Fixes https://todo.sr.ht/~sircmpwn/gmni/22
2020-09-24 10:33:54 -04:00
Eyal Sawady 0a03e6dadf Fix a bug causing some text to be duplicated
For example:

$ gmnlm gemini://gemini.circumlunar.space
[...]
11) A lissper.strangled.net/mirrorlist/ A lisssources
   t of mirrored services
[...]
2020-09-24 10:33:27 -04:00
Eyal Sawady 174fbd5d09 Fix memory leaks 2020-09-23 12:55:16 -04:00
Drew DeVault 0976b0e446 Fix search command 2020-09-23 12:55:12 -04:00
Arav K 9551d0a382 Add 'p' to view link URL without visiting
Answers https://todo.sr.ht/~sircmpwn/gmni/13 by adding a 'p' command
that, when given a (valid) link number, provides the URL that that link
leads to.
2020-09-23 09:12:53 -04:00
Leon Henrik Plickat b25b4576e3 Correctly abort when launched with invalid URL
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.
2020-09-22 09:07:20 -04:00
Arav K 60cf41e7dd Add 'H' to view all page history
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.
2020-09-22 09:06:16 -04:00
Drew DeVault 39339c348f Fix issues with tofu.c 2020-09-21 22:22:18 -04:00
Eyal Sawady d6777ec278 gemini_response_finish: handle null ssl connection 2020-09-21 22:22:09 -04:00
Drew DeVault 02f6af6615 Implement TOFU 2020-09-21 16:06:43 -04:00
Eyal Sawady c7592c6a5c save_bookmark: fix bookmark file creation 2020-09-21 07:57:42 -04:00
Drew DeVault eb2873b2eb gmnlm.c: add limits.h
Supposedly fixes OpenBSD
2020-09-21 07:56:20 -04:00