Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add single step update #1639

Merged
merged 2 commits into from
Nov 18, 2024
Merged

Add single step update #1639

merged 2 commits into from
Nov 18, 2024

Conversation

bryteise
Copy link
Member

No description provided.

When allocating the buffer for a version string, the size should be
one greater than the max string size as the null string is inserted at
the content size index which leads to a buffer overflow.

Signed-off-by: William Douglas <william.douglas@intel.com>
@bryteise bryteise force-pushed the add-single-step-update branch 4 times, most recently from 1c95581 to ac97f45 Compare November 17, 2024 22:56
Copy link
Member

@bwarden bwarden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the help/usage text, my only suggestion is to consider whether "incremental" might be less ambiguous than "single-step".

docs/swupd.1.rst Outdated Show resolved Hide resolved
src/cmds/update.c Outdated Show resolved Hide resolved
swupd.zsh Outdated Show resolved Hide resolved
@bryteise
Copy link
Member Author

Thanks, I am not great at coming up with clear names.


static int requested_version = -1;
static bool download_only = false;
static bool update_search_file_index = false;
static bool keepcache = false;
static bool cmdline_option_single_step = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static bool cmdline_option_single_step = false;
static bool cmdline_option_incremental = false;

@@ -142,11 +144,11 @@ int add_included_manifests(struct manifest *mom, struct list **subs)
return 0;
}

static enum swupd_code check_versions(int *current_version, int *server_version, int req_version, char *path_prefix)
static enum swupd_code check_versions(int *current_version, int *server_version, int req_version, char *path_prefix, bool single_step)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static enum swupd_code check_versions(int *current_version, int *server_version, int req_version, char *path_prefix, bool single_step)
static enum swupd_code check_versions(int *current_version, int *server_version, int req_version, char *path_prefix, bool incremental)

{
int ret;

ret = read_versions(current_version, server_version, path_prefix);
ret = read_versions(current_version, server_version, path_prefix, single_step);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ret = read_versions(current_version, server_version, path_prefix, single_step);
ret = read_versions(current_version, server_version, path_prefix, incremental);

@@ -285,7 +291,7 @@ enum swupd_code execute_update_extra(extra_proc_fn_t post_update_fn, extra_proc_

/* get versions */
timelist_timer_start(globals.global_times, "Get versions");
ret = check_versions(&current_version, &server_version, requested_version, globals.path_prefix);
ret = check_versions(&current_version, &server_version, requested_version, globals.path_prefix, cmdline_option_single_step);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ret = check_versions(&current_version, &server_version, requested_version, globals.path_prefix, cmdline_option_single_step);
ret = check_versions(&current_version, &server_version, requested_version, globals.path_prefix, cmdline_option_incremental);

@@ -617,6 +635,9 @@ static bool parse_opt(int opt, char *optarg)
cmdline_option_3rd_party = optarg_to_bool(optarg);
return true;
#endif
case FLAG_INCREMENTAL:
cmdline_option_single_step = optarg_to_bool(optarg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cmdline_option_single_step = optarg_to_bool(optarg);
cmdline_option_incremental = optarg_to_bool(optarg);

@@ -697,7 +718,7 @@ enum swupd_code update_main(int argc, char **argv)
ret = check_update();

#ifdef THIRDPARTY
if (cmdline_option_3rd_party) {
if (cmdline_option_3rd_party && !cmdline_option_single_step) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (cmdline_option_3rd_party && !cmdline_option_single_step) {
if (cmdline_option_3rd_party && !cmdline_option_incremental) {

@@ -707,7 +728,7 @@ enum swupd_code update_main(int argc, char **argv)
ret = execute_update();

#ifdef THIRDPARTY
if (cmdline_option_3rd_party) {
if (cmdline_option_3rd_party && !cmdline_option_single_step) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (cmdline_option_3rd_party && !cmdline_option_single_step) {
if (cmdline_option_3rd_party && !cmdline_option_incremental) {

src/swupd.h Outdated
@@ -167,7 +167,7 @@ extern enum swupd_code walk_tree(struct manifest *, const char *, bool, const re

extern int get_latest_version(char *v_url);
extern int get_int_from_url(const char *url);
extern enum swupd_code read_versions(int *current_version, int *server_version, char *path_prefix);
extern enum swupd_code read_versions(int *current_version, int *server_version, char *path_prefix, bool single_step);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
extern enum swupd_code read_versions(int *current_version, int *server_version, char *path_prefix, bool single_step);
extern enum swupd_code read_versions(int *current_version, int *server_version, char *path_prefix, bool incremental);

@@ -330,15 +434,21 @@ bool get_distribution_string(char *path_prefix, char *dist)
return true;
}

enum swupd_code read_versions(int *current_version, int *server_version, char *path_prefix)
enum swupd_code read_versions(int *current_version, int *server_version, char *path_prefix, bool single_step)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
enum swupd_code read_versions(int *current_version, int *server_version, char *path_prefix, bool single_step)
enum swupd_code read_versions(int *current_version, int *server_version, char *path_prefix, bool incremental)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update-incremental.bats

@bryteise
Copy link
Member Author

Monday morning grep X(.

Allow users to update by stepping through each release between their
current version and the latest. This option is primarily for cases
where update is failing due to memory or disk space running out when
updating normally.

Signed-off-by: William Douglas <william.douglas@intel.com>
@bryteise
Copy link
Member Author

Sorry about that. Fixed up commit message too. Thanks for rechecking.

Copy link
Member

@bwarden bwarden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've all been there :)

@bryteise bryteise merged commit 6df531f into master Nov 18, 2024
30 checks passed
@bryteise bryteise deleted the add-single-step-update branch November 18, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants