Skip to content

Commit

Permalink
Release 1.2.1
Browse files Browse the repository at this point in the history
- Fix Issue 5 in Bugs.md
- Fix Issue 6 in Bugs.md
- Apply clang-format
- Introduce -fanalyzer analysis for gcc compilation
  • Loading branch information
Cagebreak Signing Key 1 committed May 24, 2020
1 parent fa8d3ba commit e35da69
Show file tree
Hide file tree
Showing 21 changed files with 310 additions and 60 deletions.
22 changes: 20 additions & 2 deletions Bugs.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ Steps to reproduce:

### Issue 4

github issue number: #1
Fixed: 1.1.0
* github issue number: #1
* Fixed: 1.1.0

This issue is code duplication in `parse.c`.

Expand All @@ -79,3 +79,21 @@ PS: As a side effect, this would allow quirky statements such as
`bind dbind r hsplit` which would bind the d key to binding the r key to
split the output...
```

### Issue 5

* github issue number : N/A
* Fixed: 1.2.1

Cagebreak up to and including release 1.2.0 does not warn of irreproducibility
if a different compiler or compiler version is used. This makes cagebreak
difficult to reproduce.

### Issue 6

* github issue number : N/A
* Fixed: 1.2.1

Our fuzzing framework up to and including release 1.2.0 does not the limit line
lengths. This can crash the fuzzing framework with a segfault due to running
out of memory.
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,33 @@ Nonetheless, don't be intimidated by the (slightly lengthy) release checklist or
part of this file. Do what you can, open an issue and we will collaborate
toward a solution.

### GCC and -fanalyzer

Cagebreak should compile with any reasonably new gcc or clang. Consider
a gcc version of at least [10.1](https://gcc.gnu.org/gcc-10/changes.html) if
you want to get the benefit of the brand-new
[-fanalyzer](https://gcc.gnu.org/onlinedocs/gcc/Static-Analyzer-Options.html)
flag. However, this new flag sometimes produces false-postives and we
selectively disable warnings for affected code segments as described below.

Meson is configured to set `CG_HAS_FANALYZE` if `-fanalyzer` is available.
Therefore, to maintain portability, false-positive fanalyzer warnings are to be
disabled using the following syntax:

```
#if CG_HAS_FANALYZE
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "WARNING OPTION"
#endif
```
and after

```
#if CG_HAS_FANALYZE
#pragma GCC diagnostic pop
#endif
```

### Branching strategy

All features are to be developed on feature branches, named after the feature.
Expand All @@ -83,7 +110,8 @@ git tag -v version
git push --tags origin master
```

and a log message roughly describing the features added in the commit.
and a log message roughly describing the features added in the commit is
included.

In the past, our git history did not always reflect this scheme.

Expand All @@ -93,6 +121,7 @@ Release checklist

* [ ] Cursory testing
* [ ] libfuzzer testing
* [ ] ninja -C build clang-format
* [ ] Version Number
* [ ] meson.build
* [ ] git tag
Expand Down Expand Up @@ -135,6 +164,9 @@ decided on this compromise to allow flexibility and security. In general we will
adapt the versions to the packages available under arch linux at the time of
release.

There are reproducibility issues up to and including release `1.2.0`. See
`Issue 5` in [Bugs.md](Bugs.md).

#### Reproducible Build Instructions

All hashes and signatures are provided for the following build instructions.
Expand All @@ -148,6 +180,11 @@ ninja -C build

For every release after 1.0.5, hashes will be provided.

1.2.1

* sha 256: 803f7667dc4997062f9ec95afcdca0cac68c82a7cf057cef83fe1ccfee33b8bc
* sha 512: 4d6b7efea10d190a153f893123b1715f290f4b131b490f3d23f489e2dd8edbb886001282849aad9575ad2f40375bbbded59c1cb6157115fcc14dd6a2a061b103

1.2.0

* sha 256: b3c6135833001a0ef600ea9628cca11f4130a524ebe748929d8f7bad034f2bf0
Expand Down
28 changes: 26 additions & 2 deletions cagebreak.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,12 @@ set_configuration(struct cg_server *server,
if(parse_rc_line(server, line) != 0) {
wlr_log(WLR_ERROR, "Error in config file \"%s\", line %d\n",
config_file_path, line_num);
fclose(config_file);
return -1;
}
}
}
fclose(config_file);
return 0;
}

Expand All @@ -218,6 +220,10 @@ get_config_file() {
}
char *config_path = malloc(
(strlen(config_home_path) + strlen(addition) + 1) * sizeof(char));
if(!config_path) {
wlr_log(WLR_ERROR, "Failed to allocate space for configuration path");
return NULL;
}
sprintf(config_path, "%s%s", config_home_path, addition);
return config_path;
}
Expand Down Expand Up @@ -256,6 +262,12 @@ main(int argc, char *argv[]) {
wlr_log_init(WLR_ERROR, NULL);
#endif

server.modes = malloc(4 * sizeof(char *));
if(!server.modes) {
wlr_log(WLR_ERROR, "Error allocating mode array");
return -1;
}

/* Wayland requires XDG_RUNTIME_DIR to be set. */
if(!getenv("XDG_RUNTIME_DIR")) {
wlr_log(WLR_ERROR, "XDG_RUNTIME_DIR is not set in the environment");
Expand All @@ -270,11 +282,15 @@ main(int argc, char *argv[]) {

server.running = true;

server.modes = malloc(4 * sizeof(char *));
server.modes[0] = strdup("top");
server.modes[1] = strdup("root");
server.modes[2] = strdup("resize");
server.modes[3] = NULL;
if(server.modes[0] == NULL || server.modes[1] == NULL ||
server.modes[2] == NULL) {
wlr_log(WLR_ERROR, "Error allocating default modes");
goto end;
}

server.nws = 1;
server.message_timeout = 2;
Expand Down Expand Up @@ -530,13 +546,18 @@ main(int argc, char *argv[]) {
wl_display_destroy_clients(server.wl_display);

end:
#if CG_HAS_FANALYZE
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wanalyzer-double-free"
#endif
for(unsigned int i = 0; server.modes[i] != NULL; ++i) {
free(server.modes[i]);
}
free(server.modes);

struct cg_output_config *output_config, *output_config_tmp;
wl_list_for_each_safe(output_config, output_config_tmp, &server.output_config, link) {
wl_list_for_each_safe(output_config, output_config_tmp,
&server.output_config, link) {
wl_list_remove(&output_config->link);
free(output_config->output_name);
free(output_config);
Expand All @@ -559,3 +580,6 @@ main(int argc, char *argv[]) {

return ret;
}
#if CG_HAS_FANALYZE
#pragma GCC diagnostic pop
#endif
1 change: 1 addition & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define CG_CONFIG_H

#mesondefine CG_HAS_XWAYLAND
#mesondefine CG_HAS_FANALYZE

#mesondefine CG_VERSION

Expand Down
16 changes: 10 additions & 6 deletions fuzz/fuzz-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@

#define _POSIX_C_SOURCE 200812L


#include "../keybinding.h"
#include "../output.h"
#include "../parse.h"
#include "../seat.h"
#include "../server.h"
#include "../output.h"
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
Expand Down Expand Up @@ -417,9 +416,13 @@ set_configuration(struct cg_server *server, char *content) {

int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
char *str = malloc(size * sizeof(char) + 1);
strncpy(str, (char *)data, size);
str[size] = 0;
if(size == 0) {
return 0;
}
int max_line_size = 256 > size ? size : 256;
char *str = malloc(sizeof(char) * max_line_size);
strncpy(str, (char *)data, max_line_size);
str[max_line_size - 1] = 0;
set_configuration(&server, str);
free(str);
keybinding_list_free(server.keybindings);
Expand Down Expand Up @@ -450,7 +453,8 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
server.modes = realloc(server.modes, 4 * sizeof(char *));

struct cg_output_config *output_config, *output_config_tmp;
wl_list_for_each_safe(output_config, output_config_tmp, &server.output_config, link) {
wl_list_for_each_safe(output_config, output_config_tmp,
&server.output_config, link) {
wl_list_remove(&output_config->link);
free(output_config->output_name);
free(output_config);
Expand Down
7 changes: 7 additions & 0 deletions idle_inhibit_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ struct cg_idle_inhibitor_v1 {
struct wl_listener destroy;
};

#if CG_HAS_FANALYZE
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
#endif
static void
idle_inhibit_v1_check_active(struct cg_server *server) {
/* As of right now, this does not check whether the inhibitor
* is visible or not.*/
bool inhibited = !wl_list_empty(&server->inhibitors);
wlr_idle_set_enabled(server->idle, NULL, !inhibited);
}
#if CG_HAS_FANALYZE
#pragma GCC diagnostic pop
#endif

static void
handle_destroy(struct wl_listener *listener, void *data) {
Expand Down
17 changes: 15 additions & 2 deletions keybinding.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,12 @@ keybinding_workspace_fullscreen(struct cg_server *server) {
}

workspace_free_tiles(output->workspaces[output->curr_workspace]);
full_screen_workspace_tiles(output,
output->workspaces[output->curr_workspace]);
if(full_screen_workspace_tiles(
server->output_layout, output->wlr_output,
output->workspaces[output->curr_workspace]) != 0) {
wlr_log(WLR_ERROR, "Failed to allocate space for fullscreen workspace");
return;
}

seat_set_focus(server->seat, current_view);
}
Expand Down Expand Up @@ -517,6 +521,10 @@ keybinding_split_output(struct cg_output *output, bool vertical) {
}

struct cg_tile *new_tile = calloc(1, sizeof(struct cg_tile));
if(!new_tile) {
wlr_log(WLR_ERROR, "Failed to allocate new tile for splitting");
return;
}
new_tile->tile.x = new_x;
new_tile->tile.y = new_y;
new_tile->tile.width = x + width - new_x;
Expand Down Expand Up @@ -741,6 +749,11 @@ keybinding_set_nws(struct cg_server *server, int nws) {
output->workspaces = new_workspaces;
for(int i = server->nws; i < nws; ++i) {
output->workspaces[i] = full_screen_workspace(output);
if(!output->workspaces[i]) {
wlr_log(WLR_ERROR, "Failed to allocate additional workspaces");
return;
}

wl_list_init(&output->workspaces[i]->views);
wl_list_init(&output->workspaces[i]->unmanaged_views);
}
Expand Down
2 changes: 1 addition & 1 deletion man/cagebreak-config.5.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% CAGEBREAK-CONFIG(1) Version 1.2 | Cagebreak Manual
% CAGEBREAK-CONFIG(1) Version 1.2.1 | Cagebreak Manual

# NAME

Expand Down
2 changes: 1 addition & 1 deletion man/cagebreak.1.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% CAGEBREAK(1) Version 1.2 | Cagebreak Manual
% CAGEBREAK(1) Version 1.2.1 | Cagebreak Manual

# NAME

Expand Down
24 changes: 22 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('cagebreak', 'c',
version: '1.2.0',
version: '1.2.1',
license: 'MIT',
default_options: [
'c_std=c11',
Expand Down Expand Up @@ -100,6 +100,14 @@ else
have_xwayland = false
endif

fanalyzer_compile_flag=[]
if cc.has_argument('-fanalyzer')
have_fanalyze=true
fanalyzer_compile_flag=[ '-fanalyzer' ]
else
have_fanalyze=false
endif

if get_option('version_override') != ''
version = '@0@'.format(get_option('version_override'))
else
Expand All @@ -108,6 +116,7 @@ endif

conf_data = configuration_data()
conf_data.set10('CG_HAS_XWAYLAND', have_xwayland)
conf_data.set10('CG_HAS_FANALYZE', have_fanalyze)
conf_data.set_quoted('CG_VERSION', version)


Expand Down Expand Up @@ -208,12 +217,23 @@ foreach name, dep : cagebreak_dependencies_dict
endif
endforeach

reproducible_build_compiler = 'gcc'
reproducible_build_compiler_version = '10.1.0'

if cc.get_id() != reproducible_build_compiler
warning('The compiler "' + cc.get_id() + '" differs from the one used to generate to binary specified in the README section "Reproducible Builds" (' + reproducible_build_compiler + ').')
endif

if cc.version() != reproducible_build_compiler_version
warning('The version of ' + cc.get_id() + ' (' + cc.version() + ') differs from the one used to generate the binary specified in the README section "Reproducible Builds" ' + reproducible_build_compiler_version + '.')
endif

executable(
meson.project_name(),
cagebreak_main_file + cagebreak_sources + cagebreak_headers,
dependencies: cagebreak_dependencies,
install: true,
link_args: fuzz_link_args,
link_args: fuzz_link_args+fanalyzer_compile_flag,
c_args: fuzz_compile_args,
)

Expand Down
Loading

0 comments on commit e35da69

Please sign in to comment.