diff --git a/Fix-off-by-one-when-checking-dev-mapper-path.patch b/Fix-off-by-one-when-checking-dev-mapper-path.patch new file mode 100644 index 0000000000000000000000000000000000000000..584fce61caec45ceb31390ea1d266d4f060ca873 --- /dev/null +++ b/Fix-off-by-one-when-checking-dev-mapper-path.patch @@ -0,0 +1,26 @@ +From 7fa6e867892cea778333c95e209feb20cebd250e Mon Sep 17 00:00:00 2001 +From: Disconnect3d +Date: Mon, 13 Apr 2020 16:14:10 +0200 +Subject: [PATCH 207/389] Fix off by one when checking "/dev/mapper/" path + +This PR fixes an off by one in `strncmp(dev->bid_name, "/dev/mapper/", 11)` check. The `"/dev/mapper/"` string literal has a length of 12 and without this fix paths like `"/dev/mapperSOMETHING"` would also be accepted. +--- + libblkid/src/devname.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libblkid/src/devname.c b/libblkid/src/devname.c +index 014b3f4..bb0211d 100644 +--- a/libblkid/src/devname.c ++++ b/libblkid/src/devname.c +@@ -258,7 +258,7 @@ set_pri: + if (dev) { + if (pri) + dev->bid_pri = pri; +- else if (!strncmp(dev->bid_name, "/dev/mapper/", 11)) { ++ else if (!strncmp(dev->bid_name, "/dev/mapper/", 12)) { + dev->bid_pri = BLKID_PRI_DM; + if (is_dm_leaf(ptname)) + dev->bid_pri += 5; +-- +1.8.3.1 + diff --git a/cal-Correctly-center-the-year.patch b/cal-Correctly-center-the-year.patch new file mode 100644 index 0000000000000000000000000000000000000000..d62561e186e689493269f8d707dd8cd4b60ebf82 --- /dev/null +++ b/cal-Correctly-center-the-year.patch @@ -0,0 +1,212 @@ +From b90829918891af8a3207bdc54a25326481b2fa6e Mon Sep 17 00:00:00 2001 +From: Aurelien LAJOIE +Date: Sat, 28 Mar 2020 23:33:40 +0100 +Subject: [PATCH 186/389] cal: Correctly center the year + +Signed-off-by: Aurelien LAJOIE +--- + misc-utils/cal.c | 7 +++---- + tests/expected/cal/weeknum-ymjw | 14 +++++++------- + tests/expected/cal/weeknum-ysjw | 14 +++++++------- + tests/expected/cal/year-ymj | 2 +- + tests/expected/cal/year-ymjw | 2 +- + tests/expected/cal/year-ysj | 2 +- + tests/expected/cal/year-ysjw | 2 +- + 7 files changed, 21 insertions(+), 22 deletions(-) + +diff --git a/misc-utils/cal.c b/misc-utils/cal.c +index 7286003..7cd6545 100644 +--- a/misc-utils/cal.c ++++ b/misc-utils/cal.c +@@ -907,11 +907,10 @@ static void monthly(const struct cal_control *ctl) + static void yearly(const struct cal_control *ctl) + { + char out[FMT_ST_CHARS]; +- int year_width = 0; ++ int year_width; + +- year_width += (ctl->week_width + 1) * (ctl->julian ? 2 : 3); +- if (ctl->julian) +- year_width--; ++ year_width = ctl->months_in_row * (ctl->week_width - 1) + ++ (ctl->months_in_row - 1) * ctl->gutter_width; + + if (ctl->header_year) { + snprintf(out, sizeof(out), "%04d", ctl->req.year); +diff --git a/tests/expected/cal/weeknum-ymjw b/tests/expected/cal/weeknum-ymjw +index d4a1072..bcf9a1e 100644 +--- a/tests/expected/cal/weeknum-ymjw ++++ b/tests/expected/cal/weeknum-ymjw +@@ -1,5 +1,5 @@ + Julian - Monday-based week with week numbers +- 2001 ++ 2001 + + January February March + Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun +@@ -33,7 +33,7 @@ Julian - Monday-based week with week numbers + 43 295 296 297 298 299 300 301 47 323 324 325 326 327 328 329 51 351 352 353 354 355 356 357 + 44 302 303 304 48 330 331 332 333 334 52 358 359 360 361 362 363 364 + 1 365 +- 2002 ++ 2002 + + January February March + Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun +@@ -67,7 +67,7 @@ Julian - Monday-based week with week numbers + 43 294 295 296 297 298 299 300 47 322 323 324 325 326 327 328 51 350 351 352 353 354 355 356 + 44 301 302 303 304 48 329 330 331 332 333 334 52 357 358 359 360 361 362 363 + 1 364 365 +- 2003 ++ 2003 + + January February March + Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun +@@ -101,7 +101,7 @@ Julian - Monday-based week with week numbers + 43 293 294 295 296 297 298 299 47 321 322 323 324 325 326 327 52 356 357 358 359 360 361 362 + 44 300 301 302 303 304 48 328 329 330 331 332 333 334 1 363 364 365 + +- 2009 ++ 2009 + + January February March + Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun +@@ -135,7 +135,7 @@ Julian - Monday-based week with week numbers + 43 292 293 294 295 296 297 298 47 320 321 322 323 324 325 326 52 355 356 357 358 359 360 361 + 44 299 300 301 302 303 304 48 327 328 329 330 331 332 333 53 362 363 364 365 + 49 334 +- 2010 ++ 2010 + + January February March + Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun +@@ -169,7 +169,7 @@ Julian - Monday-based week with week numbers + 42 291 292 293 294 295 296 297 47 326 327 328 329 330 331 332 51 354 355 356 357 358 359 360 + 43 298 299 300 301 302 303 304 48 333 334 52 361 362 363 364 365 + +- 2011 ++ 2011 + + January February March + Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun +@@ -203,7 +203,7 @@ Julian - Monday-based week with week numbers + 42 290 291 292 293 294 295 296 47 325 326 327 328 329 330 331 51 353 354 355 356 357 358 359 + 43 297 298 299 300 301 302 303 48 332 333 334 52 360 361 362 363 364 365 + 44 304 +- 2012 ++ 2012 + + January February March + Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun +diff --git a/tests/expected/cal/weeknum-ysjw b/tests/expected/cal/weeknum-ysjw +index 16b91ad..b5a8527 100644 +--- a/tests/expected/cal/weeknum-ysjw ++++ b/tests/expected/cal/weeknum-ysjw +@@ -1,5 +1,5 @@ + Julian - Sunday-based week with week numbers +- 2001 ++ 2001 + + January February March + Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat +@@ -33,7 +33,7 @@ Julian - Sunday-based week with week numbers + 43 294 295 296 297 298 299 300 47 322 323 324 325 326 327 328 51 350 351 352 353 354 355 356 + 44 301 302 303 304 48 329 330 331 332 333 334 52 357 358 359 360 361 362 363 + 53 364 365 +- 2002 ++ 2002 + + January February March + Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat +@@ -67,7 +67,7 @@ Julian - Sunday-based week with week numbers + 43 293 294 295 296 297 298 299 47 321 322 323 324 325 326 327 52 356 357 358 359 360 361 362 + 44 300 301 302 303 304 48 328 329 330 331 332 333 334 53 363 364 365 + +- 2003 ++ 2003 + + January February March + Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat +@@ -101,7 +101,7 @@ Julian - Sunday-based week with week numbers + 43 292 293 294 295 296 297 298 47 320 321 322 323 324 325 326 52 355 356 357 358 359 360 361 + 44 299 300 301 302 303 304 48 327 328 329 330 331 332 333 53 362 363 364 365 + 49 334 +- 2009 ++ 2009 + + January February March + Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat +@@ -135,7 +135,7 @@ Julian - Sunday-based week with week numbers + 43 291 292 293 294 295 296 297 48 326 327 328 329 330 331 332 52 354 355 356 357 358 359 360 + 44 298 299 300 301 302 303 304 49 333 334 53 361 362 363 364 365 + +- 2010 ++ 2010 + + January February March + Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat +@@ -169,7 +169,7 @@ Julian - Sunday-based week with week numbers + 43 290 291 292 293 294 295 296 48 325 326 327 328 329 330 331 52 353 354 355 356 357 358 359 + 44 297 298 299 300 301 302 303 49 332 333 334 53 360 361 362 363 364 365 + 45 304 +- 2011 ++ 2011 + + January February March + Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat +@@ -203,7 +203,7 @@ Julian - Sunday-based week with week numbers + 43 289 290 291 292 293 294 295 48 324 325 326 327 328 329 330 52 352 353 354 355 356 357 358 + 44 296 297 298 299 300 301 302 49 331 332 333 334 53 359 360 361 362 363 364 365 + 45 303 304 +- 2012 ++ 2012 + + January February March + Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat +diff --git a/tests/expected/cal/year-ymj b/tests/expected/cal/year-ymj +index caa3db0..f3b7143 100644 +--- a/tests/expected/cal/year-ymj ++++ b/tests/expected/cal/year-ymj +@@ -1,5 +1,5 @@ + Julian - Monday-based week +- 2006 ++ 2006 + + January February March + Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun +diff --git a/tests/expected/cal/year-ymjw b/tests/expected/cal/year-ymjw +index b62e167..e6a569e 100644 +--- a/tests/expected/cal/year-ymjw ++++ b/tests/expected/cal/year-ymjw +@@ -1,5 +1,5 @@ + Julian - Monday-based week with week numbers +- 2006 ++ 2006 + + January February March + Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun +diff --git a/tests/expected/cal/year-ysj b/tests/expected/cal/year-ysj +index 080e257..2b40099 100644 +--- a/tests/expected/cal/year-ysj ++++ b/tests/expected/cal/year-ysj +@@ -1,5 +1,5 @@ + Julian - Sunday-based week +- 2006 ++ 2006 + + January February March + Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat +diff --git a/tests/expected/cal/year-ysjw b/tests/expected/cal/year-ysjw +index 69dbae3..800ec0c 100644 +--- a/tests/expected/cal/year-ysjw ++++ b/tests/expected/cal/year-ysjw +@@ -1,5 +1,5 @@ + Julian - Sunday-based week with week numbers +- 2006 ++ 2006 + + January February March + Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat +-- +1.8.3.1 + diff --git a/cal-correctly-set-the-week-width.patch b/cal-correctly-set-the-week-width.patch new file mode 100644 index 0000000000000000000000000000000000000000..5c756b1419f77b74fbb26e19436da14611747df7 --- /dev/null +++ b/cal-correctly-set-the-week-width.patch @@ -0,0 +1,74 @@ +From a5e322f4f403af970092dad73b95cbaa54045a3d Mon Sep 17 00:00:00 2001 +From: Aurelien LAJOIE +Date: Sat, 28 Mar 2020 23:33:41 +0100 +Subject: [PATCH 187/389] cal: correctly set the week width + +There is seven values but only 6 spaces between them, that why the -1 +The value is always used with a minus one, just set it correctly instead +of always fix when used + +Signed-off-by: Aurelien LAJOIE +--- + misc-utils/cal.c | 15 ++++++++++----- + 1 file changed, 10 insertions(+), 5 deletions(-) + +diff --git a/misc-utils/cal.c b/misc-utils/cal.c +index 7cd6545..feff1e8 100644 +--- a/misc-utils/cal.c ++++ b/misc-utils/cal.c +@@ -452,6 +452,11 @@ int main(int argc, char **argv) + ctl.week_width = (ctl.day_width * DAYS_IN_WEEK) + WNUM_LEN; + } else + ctl.week_width = ctl.day_width * DAYS_IN_WEEK; ++ /* ++ * The day_width includes the space between days, ++ * as there is no leading space, remove 1 ++ * */ ++ ctl.week_width -= 1; + + if (argc == 1 && !isdigit_string(*argv)) { + usec_t x; +@@ -688,7 +693,7 @@ static void headers_init(struct cal_control *ctl) + + for (i = 0; i < MONTHS_IN_YEAR; i++) { + /* The +1 after year_len is space in between month and year. */ +- if (ctl->week_width < strlen(ctl->full_month[i]) + year_len + 1) ++ if (ctl->week_width < strlen(ctl->full_month[i]) + year_len) + ctl->header_hint = 1; + } + } +@@ -757,19 +762,19 @@ static void cal_output_header(struct cal_month *month, const struct cal_control + if (ctl->header_hint || ctl->header_year) { + for (i = month; i; i = i->next) { + snprintf(out, sizeof(out), "%s", ctl->full_month[i->month - 1]); +- center(out, ctl->week_width - 1, i->next == NULL ? 0 : ctl->gutter_width); ++ center(out, ctl->week_width, i->next == NULL ? 0 : ctl->gutter_width); + } + if (!ctl->header_year) { + my_putstring("\n"); + for (i = month; i; i = i->next) { + snprintf(out, sizeof(out), "%04d", i->year); +- center(out, ctl->week_width - 1, i->next == NULL ? 0 : ctl->gutter_width); ++ center(out, ctl->week_width, i->next == NULL ? 0 : ctl->gutter_width); + } + } + } else { + for (i = month; i; i = i->next) { + snprintf(out, sizeof(out), "%s %04d", ctl->full_month[i->month - 1], i->year); +- center(out, ctl->week_width - 1, i->next == NULL ? 0 : ctl->gutter_width); ++ center(out, ctl->week_width, i->next == NULL ? 0 : ctl->gutter_width); + } + } + my_putstring("\n"); +@@ -909,7 +914,7 @@ static void yearly(const struct cal_control *ctl) + char out[FMT_ST_CHARS]; + int year_width; + +- year_width = ctl->months_in_row * (ctl->week_width - 1) + ++ year_width = ctl->months_in_row * (ctl->week_width) + + (ctl->months_in_row - 1) * ctl->gutter_width; + + if (ctl->header_year) { +-- +1.8.3.1 + diff --git a/clang-tidy-use-ceil.patch b/clang-tidy-use-ceil.patch new file mode 100644 index 0000000000000000000000000000000000000000..182b928fac879341f59419991eca28aaaac38664 --- /dev/null +++ b/clang-tidy-use-ceil.patch @@ -0,0 +1,31 @@ +From ed23cbce644987eb41c0de3bef47ac7e7a32f03a Mon Sep 17 00:00:00 2001 +From: Rosen Penev +Date: Sat, 18 Apr 2020 22:34:55 -0700 +Subject: [PATCH 220/389] [clang-tidy] use ceil + +Found with bugprone-incorrect-roundings + +Signed-off-by: Rosen Penev +--- + sys-utils/hwclock.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c +index 1026adc..37abab4 100644 +--- a/sys-utils/hwclock.c ++++ b/sys-utils/hwclock.c +@@ -608,9 +608,8 @@ set_hardware_clock_exact(const struct hwclock_control *ctl, + } + + newhwtime = sethwtime +- + (int)(time_diff(nowsystime, refsystime) +- - delay /* don't count this */ +- + 0.5 /* for rounding */); ++ + ceil(time_diff(nowsystime, refsystime) ++ - delay /* don't count this */); + if (ctl->verbose) + printf(_("%ld.%06ld is close enough to %ld.%06ld (%.6f < %.6f)\n" + "Set RTC to %ld (%ld + %d; refsystime = %ld.%06ld)\n"), +-- +1.8.3.1 + diff --git a/do-not-excute-mountpoint-test.patch b/do-not-excute-mountpoint-test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b1b0ba9b81e533cec48dcd01bacbd18cdd1ffc81 --- /dev/null +++ b/do-not-excute-mountpoint-test.patch @@ -0,0 +1,29 @@ +From 1adecf87a9b296316fa69d141437bb398267f7bb Mon Sep 17 00:00:00 2001 +From: liuchenguang +Date: Wed, 27 May 2020 12:39:01 +0800 +Subject: [PATCH] Do not excute mountpoint test + +The mountpoint test is to check if the root directory is a mountpoint, +the expected result is that the root directory is a mountpoint. +Because the root directory isn't a mountpoint in the obs environment, +it will build failure on gerrit. +Therefore,I use this patch to skip the test. +--- + tests/commands.sh | 2 ++-- + 1 file changed, 1 insertions(+), 1 deletions(-) + +diff --git a/tests/commands.sh b/tests/commands.sh +index 5f34452..2c50589 100644 +--- a/tests/commands.sh ++++ b/tests/commands.sh +@@ -84,7 +84,7 @@ TS_CMD_MKCRAMFS=${TS_CMD_MKCRAMFS:-"${ts_commandsdir}mkfs.cramfs"} + TS_CMD_MKMINIX=${TS_CMD_MKMINIX:-"${ts_commandsdir}mkfs.minix"} + TS_CMD_MKSWAP=${TS_CMD_MKSWAP:-"${ts_commandsdir}mkswap"} + TS_CMD_MOUNT=${TS_CMD_MOUNT:-"${ts_commandsdir}mount"} +-TS_CMD_MOUNTPOINT=${TS_CMD_MOUNTPOINT:-"${ts_commandsdir}mountpoint"} ++#TS_CMD_MOUNTPOINT=${TS_CMD_MOUNTPOINT:-"${ts_commandsdir}mountpoint"} + TS_CMD_NAMEI=${TS_CMD_NAMEI-"${ts_commandsdir}namei"} + TS_CMD_PARTX=${TS_CMD_PARTX-"${ts_commandsdir}partx"} + TS_CMD_RENAME=${TS_CMD_RENAME-"${ts_commandsdir}rename"} +-- +2.23.0 diff --git a/findmnt-make-xalloc-use-mroe-robust.patch b/findmnt-make-xalloc-use-mroe-robust.patch new file mode 100644 index 0000000000000000000000000000000000000000..206df77299ea095ca1de227db3325779b977a192 --- /dev/null +++ b/findmnt-make-xalloc-use-mroe-robust.patch @@ -0,0 +1,80 @@ +From c6d8486aad9ba080504d9b1ab4ea396cb2f1b81a Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 27 Feb 2020 10:02:39 +0100 +Subject: [PATCH 087/389] findmnt: make xalloc use mroe robust + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1807003 +Signed-off-by: Karel Zak +--- + misc-utils/findmnt.c | 27 ++++++++++++++++++--------- + 1 file changed, 18 insertions(+), 9 deletions(-) + +diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c +index a4b7a1b..53f647f 100644 +--- a/misc-utils/findmnt.c ++++ b/misc-utils/findmnt.c +@@ -533,22 +533,28 @@ static char *get_data(struct libmnt_fs *fs, int num) + break; + } + case COL_TARGET: +- str = xstrdup(mnt_fs_get_target(fs)); ++ if (mnt_fs_get_target(fs)) ++ str = xstrdup(mnt_fs_get_target(fs)); + break; + case COL_FSTYPE: +- str = xstrdup(mnt_fs_get_fstype(fs)); ++ if (mnt_fs_get_fstype(fs)) ++ str = xstrdup(mnt_fs_get_fstype(fs)); + break; + case COL_OPTIONS: +- str = xstrdup(mnt_fs_get_options(fs)); ++ if (mnt_fs_get_options(fs)) ++ str = xstrdup(mnt_fs_get_options(fs)); + break; + case COL_VFS_OPTIONS: +- str = xstrdup(mnt_fs_get_vfs_options(fs)); ++ if (mnt_fs_get_vfs_options(fs)) ++ str = xstrdup(mnt_fs_get_vfs_options(fs)); + break; + case COL_FS_OPTIONS: +- str = xstrdup(mnt_fs_get_fs_options(fs)); ++ if (mnt_fs_get_fs_options(fs)) ++ str = xstrdup(mnt_fs_get_fs_options(fs)); + break; + case COL_OPT_FIELDS: +- str = xstrdup(mnt_fs_get_optional_fields(fs)); ++ if (mnt_fs_get_optional_fields(fs)) ++ str = xstrdup(mnt_fs_get_optional_fields(fs)); + break; + case COL_UUID: + str = get_tag(fs, "UUID", col_id); +@@ -582,7 +588,8 @@ static char *get_data(struct libmnt_fs *fs, int num) + str = get_vfs_attr(fs, col_id); + break; + case COL_FSROOT: +- str = xstrdup(mnt_fs_get_root(fs)); ++ if (mnt_fs_get_root(fs)) ++ str = xstrdup(mnt_fs_get_root(fs)); + break; + case COL_TID: + if (mnt_fs_get_tid(fs)) +@@ -659,12 +666,14 @@ static char *get_tabdiff_data(struct libmnt_fs *old_fs, + break; + case COL_OLD_OPTIONS: + if (old_fs && (change == MNT_TABDIFF_REMOUNT || +- change == MNT_TABDIFF_UMOUNT)) ++ change == MNT_TABDIFF_UMOUNT) ++ && mnt_fs_get_options(old_fs)) + str = xstrdup(mnt_fs_get_options(old_fs)); + break; + case COL_OLD_TARGET: + if (old_fs && (change == MNT_TABDIFF_MOVE || +- change == MNT_TABDIFF_UMOUNT)) ++ change == MNT_TABDIFF_UMOUNT) ++ && mnt_fs_get_target(old_fs)) + str = xstrdup(mnt_fs_get_target(old_fs)); + break; + default: +-- +1.8.3.1 + diff --git a/fsck.cramfs-fix-macro-usage.patch b/fsck.cramfs-fix-macro-usage.patch new file mode 100644 index 0000000000000000000000000000000000000000..283ea9b03e17a374e407138164000cbd98445520 --- /dev/null +++ b/fsck.cramfs-fix-macro-usage.patch @@ -0,0 +1,29 @@ +From d52786aab7fa7d8ce717ad9fe8fbf84bc746c75a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 25 Feb 2020 13:29:08 +0100 +Subject: [PATCH 140/389] fsck.cramfs: fix macro usage + +Autotoolz does not define HAVE_LCHOWN when the condition is false, +so it is appropriate to use #ifdef/#ifndef as everywhere else. + +Signed-off-by: Karel Zak +--- + disk-utils/fsck.cramfs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c +index a819951..3a43dd7 100644 +--- a/disk-utils/fsck.cramfs.c ++++ b/disk-utils/fsck.cramfs.c +@@ -368,7 +368,7 @@ static int uncompress_block(void *src, size_t len) + return stream.total_out; + } + +-#if !HAVE_LCHOWN ++#ifndef HAVE_LCHOWN + #define lchown chown + #endif + +-- +1.8.3.1 + diff --git a/hwclock-fix-audit-exit-status.patch b/hwclock-fix-audit-exit-status.patch new file mode 100644 index 0000000000000000000000000000000000000000..86def9f22df75d35c6a24bdbe419fe8780224d56 --- /dev/null +++ b/hwclock-fix-audit-exit-status.patch @@ -0,0 +1,31 @@ +From 189edf1fe501ea39b35911337eab1740888fae7a Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 27 Feb 2020 14:04:55 +0100 +Subject: [PATCH 089/389] hwclock: fix audit exit status + +According to audit_log_user_message(3) result 1 is "success" and 0 is +"failed", we use standard EXIT_{SUCCESS,FAILURE} macros with reverse +status. + +Addresses: https://github.com/karelzak/util-linux/issues/966 +Signed-off-by: Karel Zak +--- + sys-utils/hwclock.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c +index 1191a85..89d8a1f 100644 +--- a/sys-utils/hwclock.c ++++ b/sys-utils/hwclock.c +@@ -1464,7 +1464,7 @@ hwclock_exit(const struct hwclock_control *ctl + if (ctl->hwaudit_on && !ctl->testing) { + audit_log_user_message(hwaudit_fd, AUDIT_USYS_CONFIG, + "op=change-system-time", NULL, NULL, NULL, +- status); ++ status == EXIT_SUCCESS ? 1 : 0); + } + close(hwaudit_fd); + #endif +-- +1.8.3.1 + diff --git a/kill-include-sys-types.h-before-checking-SYS_pidfd_s.patch b/kill-include-sys-types.h-before-checking-SYS_pidfd_s.patch new file mode 100644 index 0000000000000000000000000000000000000000..1c05eff3cb3e71b606841dea32fb340160ce2ee4 --- /dev/null +++ b/kill-include-sys-types.h-before-checking-SYS_pidfd_s.patch @@ -0,0 +1,61 @@ +From 3cfde0370d3a8949df0c5bcf447cec6692910ed2 Mon Sep 17 00:00:00 2001 +From: Sami Kerola +Date: Sat, 15 Feb 2020 21:12:50 +0000 +Subject: [PATCH 045/389] kill: include sys/types.h before checking + SYS_pidfd_send_signal + +Including sys/types.h must happen before SYS_pidfd_send_signal is checked, +because that header defines variable in normal conditions. When sys/types.h +does not have SYS_pidfd_send_signal then fallback is defined in config.h +that is included by default, and has therefore worked fine before and after +this change. + +Signed-off-by: Sami Kerola +--- + include/pidfd-utils.h | 18 ++++++++++-------- + 1 file changed, 10 insertions(+), 8 deletions(-) + +diff --git a/include/pidfd-utils.h b/include/pidfd-utils.h +index 5933465..0baedd2 100644 +--- a/include/pidfd-utils.h ++++ b/include/pidfd-utils.h +@@ -1,26 +1,28 @@ + #ifndef UTIL_LINUX_PIDFD_UTILS + #define UTIL_LINUX_PIDFD_UTILS + +-#if defined(__linux__) && defined(SYS_pidfd_send_signal) +-# include ++#if defined(__linux__) + # include ++# if defined(SYS_pidfd_send_signal) ++# include + +-# ifndef HAVE_PIDFD_OPEN ++# ifndef HAVE_PIDFD_OPEN + static inline int pidfd_send_signal(int pidfd, int sig, siginfo_t *info, + unsigned int flags) + { + return syscall(SYS_pidfd_send_signal, pidfd, sig, info, flags); + } +-# endif ++# endif + +-# ifndef HAVE_PIDFD_SEND_SIGNAL ++# ifndef HAVE_PIDFD_SEND_SIGNAL + static inline int pidfd_open(pid_t pid, unsigned int flags) + { + return syscall(SYS_pidfd_open, pid, flags); + } +-# endif ++# endif + +-# define UL_HAVE_PIDFD 1 ++# define UL_HAVE_PIDFD 1 + +-#endif /* __linux__ && SYS_pidfd_send_signal */ ++# endif /* SYS_pidfd_send_signal */ ++#endif /* __linux__ */ + #endif /* UTIL_LINUX_PIDFD_UTILS */ +-- +1.8.3.1 + diff --git a/lib-mangle-check-for-the-NULL-string-argument.patch b/lib-mangle-check-for-the-NULL-string-argument.patch new file mode 100644 index 0000000000000000000000000000000000000000..c479e2eea3307fe0db029ae8c394a846e78929c5 --- /dev/null +++ b/lib-mangle-check-for-the-NULL-string-argument.patch @@ -0,0 +1,40 @@ +From e368d0ad5da392d35afdff8699089346e824d7ac Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ga=C3=ABl=20PORTAY?= +Date: Fri, 20 Mar 2020 16:21:58 -0400 +Subject: [PATCH 152/389] lib/mangle: check for the NULL string argument +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This patch prevents to call the function strlen() with a NULL string +argument that leads to a segmentation fault. + +Signed-off-by: Gaël PORTAY +--- + include/mangle.h | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/include/mangle.h b/include/mangle.h +index 0a4b60c..08c66cb 100644 +--- a/include/mangle.h ++++ b/include/mangle.h +@@ -14,12 +14,14 @@ extern char *unmangle(const char *s, const char **end); + + static inline void unmangle_string(char *s) + { +- unmangle_to_buffer(s, s, strlen(s) + 1); ++ if (s) ++ unmangle_to_buffer(s, s, strlen(s) + 1); + } + + static inline void unhexmangle_string(char *s) + { +- unhexmangle_to_buffer(s, s, strlen(s) + 1); ++ if (s) ++ unhexmangle_to_buffer(s, s, strlen(s) + 1); + } + + #endif /* UTIL_LINUX_MANGLE_H */ +-- +1.8.3.1 + diff --git a/lib-strutils-fix-floating-point-exception.patch b/lib-strutils-fix-floating-point-exception.patch new file mode 100644 index 0000000000000000000000000000000000000000..613105e15fd7de22c3543841e66d329336fd2a5c --- /dev/null +++ b/lib-strutils-fix-floating-point-exception.patch @@ -0,0 +1,27 @@ +From 1186cdf336e9d29089de54ff59dba6d2ee1bd803 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 28 Apr 2020 12:28:59 +0200 +Subject: [PATCH 233/389] lib/strutils: fix floating point exception + +Addresses: https://github.com/karelzak/util-linux/issues/1017 +Signed-off-by: Karel Zak +--- + lib/strutils.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/strutils.c b/lib/strutils.c +index e1629fb..609ef08 100644 +--- a/lib/strutils.c ++++ b/lib/strutils.c +@@ -195,7 +195,7 @@ check_suffix: + frac /= 10; /* remove last digit from frac */ + frac_poz *= 10; + +- if (seg) ++ if (seg && seg_div / seg) + x += frac_base / (seg_div / seg); + } while (frac); + } +-- +1.8.3.1 + diff --git a/libfdisk-fix-alignment-logic-for-tiny-partitions.patch b/libfdisk-fix-alignment-logic-for-tiny-partitions.patch new file mode 100644 index 0000000000000000000000000000000000000000..dd843743f3a3006454e10bb6adff997876bbc8a8 --- /dev/null +++ b/libfdisk-fix-alignment-logic-for-tiny-partitions.patch @@ -0,0 +1,62 @@ +From 89c0297bcc313b69347ee110c422e84857bd3265 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 29 Apr 2020 11:10:54 +0200 +Subject: [PATCH 235/389] libfdisk: fix alignment logic for tiny partitions + +Addresses: https://github.com/karelzak/util-linux/issues/1018 (second case) +Signed-off-by: Karel Zak +--- + libfdisk/src/alignment.c | 10 ++++++---- + libfdisk/src/dos.c | 5 ++++- + 2 files changed, 10 insertions(+), 5 deletions(-) + +diff --git a/libfdisk/src/alignment.c b/libfdisk/src/alignment.c +index 4ae5ff0..cf79180 100644 +--- a/libfdisk/src/alignment.c ++++ b/libfdisk/src/alignment.c +@@ -140,12 +140,14 @@ fdisk_sector_t fdisk_align_lba_in_range(struct fdisk_context *cxt, + { + fdisk_sector_t res; + +- start = fdisk_align_lba(cxt, start, FDISK_ALIGN_UP); +- stop = fdisk_align_lba(cxt, stop, FDISK_ALIGN_DOWN); ++ DBG(CXT, ul_debugobj(cxt, "LBA: align in range <%ju..%ju>", (uintmax_t) start, (uintmax_t) stop)); + +- if (lba > start && lba < stop +- && (lba - start) < (cxt->grain / cxt->sector_size)) { ++ if (start + (cxt->grain / cxt->sector_size) <= stop) { ++ start = fdisk_align_lba(cxt, start, FDISK_ALIGN_UP); ++ stop = fdisk_align_lba(cxt, stop, FDISK_ALIGN_DOWN); ++ } + ++ if (start + (cxt->grain / cxt->sector_size) > stop) { + DBG(CXT, ul_debugobj(cxt, "LBA: area smaller than grain, don't align")); + res = lba; + goto done; +diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c +index 79a5552..6268d2f 100644 +--- a/libfdisk/src/dos.c ++++ b/libfdisk/src/dos.c +@@ -1236,7 +1236,11 @@ static int add_partition(struct fdisk_context *cxt, size_t n, + struct pte *pe = self_pte(cxt, n); + + assert(pe); ++ assert(start >= cxt->first_lba); ++ + pe->offset = start - cxt->first_lba; ++ DBG(LABEL, ul_debug("DOS: setting EBR offset to %ju [start=%ju]", pe->offset, start)); ++ + if (pe->offset == l->ext_offset) { /* must be corrected */ + pe->offset++; + if (cxt->first_lba == 1) +@@ -1337,7 +1341,6 @@ static int add_partition(struct fdisk_context *cxt, size_t n, + set_partition(cxt, n, 0, start, stop, sys, fdisk_partition_is_bootable(pa)); + if (n > 4) { + struct pte *pe = self_pte(cxt, n); +- + assert(pe); + set_partition(cxt, n - 1, 1, pe->offset, stop, + MBR_DOS_EXTENDED_PARTITION, 0); +-- +1.8.3.1 + diff --git a/libfdisk-fix-partition-calculation-for-BLKPG_-ioctls.patch b/libfdisk-fix-partition-calculation-for-BLKPG_-ioctls.patch new file mode 100644 index 0000000000000000000000000000000000000000..9721ea62f86d87376d4dbeba217c834d80bf7168 --- /dev/null +++ b/libfdisk-fix-partition-calculation-for-BLKPG_-ioctls.patch @@ -0,0 +1,59 @@ +From 6a4d53ce6466fc97c0ee13846cd1bf7bdd7bfef0 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 6 May 2020 13:32:46 +0200 +Subject: [PATCH 243/389] libfdisk: fix partition calculation for BLKPG_* + ioctls + +The include/partx.h interface we use in util-linux uses 512-byte +sectors, but libfdisk uses real sector sizes. + +Signed-off-by: Karel Zak +--- + libfdisk/src/context.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c +index 153f1a8..69038af 100644 +--- a/libfdisk/src/context.c ++++ b/libfdisk/src/context.c +@@ -882,6 +882,7 @@ int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org) + struct fdisk_partition **rem = NULL, **add = NULL, **upd = NULL; + int change, rc = 0, err = 0; + size_t nparts, i, nadds = 0, nupds = 0, nrems = 0; ++ unsigned int ssf; + + DBG(CXT, ul_debugobj(cxt, "rereading changes")); + +@@ -915,6 +916,9 @@ int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org) + goto done; + } + ++ /* sector size factor -- used to recount from real to 512-byte sectors */ ++ ssf = cxt->sector_size / 512; ++ + for (i = 0; i < nrems; i++) { + pa = rem[i]; + DBG(PART, ul_debugobj(pa, "#%zu calling BLKPG_DEL_PARTITION", pa->partno)); +@@ -926,7 +930,8 @@ int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org) + for (i = 0; i < nupds; i++) { + pa = upd[i]; + DBG(PART, ul_debugobj(pa, "#%zu calling BLKPG_RESIZE_PARTITION", pa->partno)); +- if (partx_resize_partition(cxt->dev_fd, pa->partno + 1, pa->start, pa->size) != 0) { ++ if (partx_resize_partition(cxt->dev_fd, pa->partno + 1, ++ pa->start * ssf, pa->size * ssf) != 0) { + fdisk_warn(cxt, _("Failed to update system information about partition %zu"), pa->partno + 1); + err++; + } +@@ -934,7 +939,8 @@ int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org) + for (i = 0; i < nadds; i++) { + pa = add[i]; + DBG(PART, ul_debugobj(pa, "#%zu calling BLKPG_ADD_PARTITION", pa->partno)); +- if (partx_add_partition(cxt->dev_fd, pa->partno + 1, pa->start, pa->size) != 0) { ++ if (partx_add_partition(cxt->dev_fd, pa->partno + 1, ++ pa->start * ssf, pa->size * ssf) != 0) { + fdisk_warn(cxt, _("Failed to add partition %zu to system"), pa->partno + 1); + err++; + } +-- +1.8.3.1 + diff --git a/libfdisk-make-sure-we-check-for-maximal-number-of-pa.patch b/libfdisk-make-sure-we-check-for-maximal-number-of-pa.patch new file mode 100644 index 0000000000000000000000000000000000000000..be1c0be69535e1583d81883516f10f1172d4bf87 --- /dev/null +++ b/libfdisk-make-sure-we-check-for-maximal-number-of-pa.patch @@ -0,0 +1,30 @@ +From b80fb30a5b79ce2cc8c7486e1435ec061aa79e2f Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 28 Apr 2020 12:58:42 +0200 +Subject: [PATCH 234/389] libfdisk: make sure we check for maximal number of + partitions + +Addresses: https://github.com/karelzak/util-linux/issues/1018 +Signed-off-by: Karel Zak +--- + libfdisk/src/dos.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c +index 5e8ad17..79a5552 100644 +--- a/libfdisk/src/dos.c ++++ b/libfdisk/src/dos.c +@@ -1756,8 +1756,8 @@ static int dos_add_partition(struct fdisk_context *cxt, + if (last + grain < cxt->total_sectors - 1) + free_sectors = 1; + +- if (!free_primary && cxt->label->nparts_max >= MAXIMUM_PARTS) { +- fdisk_info(cxt, _("The maximum number of partitions has " ++ if (cxt->label->nparts_max >= MAXIMUM_PARTS) { ++ fdisk_warnx(cxt, _("The maximum number of partitions has " + "been created.")); + return -EINVAL; + } +-- +1.8.3.1 + diff --git a/libfdisk-remove-unwanted-assert.patch b/libfdisk-remove-unwanted-assert.patch new file mode 100644 index 0000000000000000000000000000000000000000..df967a445e57c5b463eae3047044de4e6c7dc24c --- /dev/null +++ b/libfdisk-remove-unwanted-assert.patch @@ -0,0 +1,25 @@ +From ca6e434a7d2ee1110b70c0847c4cab1b22f94fb7 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 24 Mar 2020 10:52:54 +0100 +Subject: [PATCH 158/389] libfdisk: remove unwanted assert() + +Signed-off-by: Karel Zak +--- + libfdisk/src/label.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/libfdisk/src/label.c b/libfdisk/src/label.c +index 0f6d85a..8e428da 100644 +--- a/libfdisk/src/label.c ++++ b/libfdisk/src/label.c +@@ -614,7 +614,6 @@ void fdisk_label_set_changed(struct fdisk_label *lb, int changed) + */ + int fdisk_label_is_changed(const struct fdisk_label *lb) + { +- assert(lb); + return lb ? lb->changed : 0; + } + +-- +1.8.3.1 + diff --git a/libfdisk-script-accept-sector-size-ignore-unknown-he.patch b/libfdisk-script-accept-sector-size-ignore-unknown-he.patch new file mode 100644 index 0000000000000000000000000000000000000000..e7d7824fac5e11702339eda20d0059e80c3f8904 --- /dev/null +++ b/libfdisk-script-accept-sector-size-ignore-unknown-he.patch @@ -0,0 +1,135 @@ +From d8c68b52cc939a16f04ec976648a37f5f5de718c Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 4 Feb 2020 15:11:19 +0100 +Subject: [PATCH 021/389] libfdisk: (script) accept sector-size, ignore unknown + headers + +- add sector-size between supported headers (already in --dump output) + +- report unknown headers by -ENOTSUP + +- ignore ENOTSUP in sfdisk (but print warning) and in fdisk_script_read_file() + +Addresses: https://github.com/karelzak/util-linux/issues/949 +Signed-off-by: Karel Zak +--- + disk-utils/sfdisk.c | 6 +++++- + libfdisk/src/script.c | 49 ++++++++++++++++++++++++++----------------------- + 2 files changed, 31 insertions(+), 24 deletions(-) + +diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c +index 0db797b..e08862a 100644 +--- a/disk-utils/sfdisk.c ++++ b/disk-utils/sfdisk.c +@@ -1823,7 +1823,11 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv) + } + + rc = fdisk_script_read_line(dp, stdin, buf, sizeof(buf)); +- if (rc < 0) { ++ if (rc == -ENOTSUP) { ++ buf[sizeof(buf) - 1] = '\0'; ++ fdisk_warnx(sf->cxt, _("Unknown script header '%s' -- ignore."), buf); ++ continue; ++ } else if (rc < 0) { + DBG(PARSE, ul_debug("script parsing failed, trying sfdisk specific commands")); + buf[sizeof(buf) - 1] = '\0'; + rc = loop_control_commands(sf, dp, buf); +diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c +index a21771b..d3e67fa 100644 +--- a/libfdisk/src/script.c ++++ b/libfdisk/src/script.c +@@ -805,8 +805,12 @@ static inline int is_header_line(const char *s) + /* parses ": value", note modifies @s*/ + static int parse_line_header(struct fdisk_script *dp, char *s) + { +- int rc = -EINVAL; ++ size_t i; + char *name, *value; ++ static const char *supported[] = { ++ "label", "unit", "label-id", "device", "grain", ++ "first-lba", "last-lba", "table-length", "sector-size" ++ }; + + DBG(SCRIPT, ul_debugobj(dp, " parse header '%s'", s)); + +@@ -816,7 +820,7 @@ static int parse_line_header(struct fdisk_script *dp, char *s) + name = s; + value = strchr(s, ':'); + if (!value) +- goto done; ++ return -EINVAL; + *value = '\0'; + value++; + +@@ -825,32 +829,30 @@ static int parse_line_header(struct fdisk_script *dp, char *s) + ltrim_whitespace((unsigned char *) value); + rtrim_whitespace((unsigned char *) value); + ++ if (!*name || !*value) ++ return -EINVAL; ++ ++ /* check header name */ ++ for (i = 0; i < ARRAY_SIZE(supported); i++) { ++ if (strcmp(name, supported[i]) == 0) ++ break; ++ } ++ if (i == ARRAY_SIZE(supported)) ++ return -ENOTSUP; ++ ++ /* header specific actions */ + if (strcmp(name, "label") == 0) { + if (dp->cxt && !fdisk_get_label(dp->cxt, value)) +- goto done; /* unknown label name */ ++ return -EINVAL; /* unknown label name */ + dp->force_label = 1; ++ + } else if (strcmp(name, "unit") == 0) { + if (strcmp(value, "sectors") != 0) +- goto done; /* only "sectors" supported */ +- } else if (strcmp(name, "label-id") == 0 +- || strcmp(name, "device") == 0 +- || strcmp(name, "grain") == 0 +- || strcmp(name, "first-lba") == 0 +- || strcmp(name, "last-lba") == 0 +- || strcmp(name, "table-length") == 0) { +- ; /* whatever is possible */ +- } else +- goto done; /* unknown header */ ++ return -EINVAL; /* only "sectors" supported */ + +- if (*name && *value) +- rc = fdisk_script_set_header(dp, name, value); +-done: +- if (rc) +- DBG(SCRIPT, ul_debugobj(dp, "header parse error: " +- "[rc=%d, name='%s', value='%s']", +- rc, name, value)); +- return rc; ++ } + ++ return fdisk_script_set_header(dp, name, value); + } + + /* returns zero terminated string with next token and @str is updated */ +@@ -1363,7 +1365,8 @@ int fdisk_script_set_fgets(struct fdisk_script *dp, + * + * Reads next line into dump. + * +- * Returns: 0 on success, <0 on error, 1 when nothing to read. ++ * Returns: 0 on success, <0 on error, 1 when nothing to read. For unknown headers ++ * returns -ENOTSUP, it's usually safe to ignore this error. + */ + int fdisk_script_read_line(struct fdisk_script *dp, FILE *f, char *buf, size_t bufsz) + { +@@ -1428,7 +1431,7 @@ int fdisk_script_read_file(struct fdisk_script *dp, FILE *f) + + while (!feof(f)) { + rc = fdisk_script_read_line(dp, f, buf, sizeof(buf)); +- if (rc) ++ if (rc && rc != -ENOTSUP) + break; + } + +-- +1.8.3.1 + diff --git a/libfdisk-script-fix-memory-leak.patch b/libfdisk-script-fix-memory-leak.patch new file mode 100644 index 0000000000000000000000000000000000000000..3859b490e6d4b3b9c831e6ea650f1bd0e2993b7c --- /dev/null +++ b/libfdisk-script-fix-memory-leak.patch @@ -0,0 +1,35 @@ +From d74b16bdf1205e027eb0dab15845b071435f397a Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 4 Feb 2020 15:54:10 +0100 +Subject: [PATCH 022/389] libfdisk: (script) fix memory leak + +Signed-off-by: Karel Zak +--- + libfdisk/src/script.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c +index d3e67fa..6f66f88 100644 +--- a/libfdisk/src/script.c ++++ b/libfdisk/src/script.c +@@ -192,6 +192,7 @@ void fdisk_unref_script(struct fdisk_script *dp) + if (dp->refcount <= 0) { + fdisk_reset_script(dp); + fdisk_unref_context(dp->cxt); ++ fdisk_unref_table(dp->table); + DBG(SCRIPT, ul_debugobj(dp, "free script")); + free(dp); + } +@@ -1459,6 +1460,9 @@ int fdisk_script_read_file(struct fdisk_script *dp, FILE *f) + * fdisk_new_script()). This context may be completely independent on + * context used for fdisk_set_script(). + * ++ * Don't forget to call fdisk_set_script(cxt, NULL); to remove this reference ++ * if no more necessary! ++ * + * Returns: <0 on error, 0 on success. + */ + int fdisk_set_script(struct fdisk_context *cxt, struct fdisk_script *dp) +-- +1.8.3.1 + diff --git a/libfdisk-script-fix-partno_from_devname.patch b/libfdisk-script-fix-partno_from_devname.patch new file mode 100644 index 0000000000000000000000000000000000000000..e1e56b74f017b19f2bbcaa5ea320bebfb4901210 --- /dev/null +++ b/libfdisk-script-fix-partno_from_devname.patch @@ -0,0 +1,38 @@ +From 243fff1dc6c3d59d9c3eb9ced472584b5ae8bbd2 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 27 Apr 2020 11:15:00 +0200 +Subject: [PATCH 229/389] libfdisk: (script) fix partno_from_devname() + +Addresses: https://github.com/karelzak/util-linux/issues/1015 +Signed-off-by: Karel Zak +--- + libfdisk/src/script.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c +index cc53c3b..8af2e54 100644 +--- a/libfdisk/src/script.c ++++ b/libfdisk/src/script.c +@@ -953,12 +953,17 @@ static int partno_from_devname(char *s) + size_t sz; + char *end, *p; + ++ if (!s || !*s) ++ return -1; ++ + sz = rtrim_whitespace((unsigned char *)s); +- p = s + sz - 1; ++ end = p = s + sz; + + while (p > s && isdigit(*(p - 1))) + p--; +- ++ if (p == end) ++ return -1; ++ end = NULL; + errno = 0; + pno = strtol(p, &end, 10); + if (errno || !end || p == end) +-- +1.8.3.1 + diff --git a/libfdisk-script-fix-segmentation-fault.patch b/libfdisk-script-fix-segmentation-fault.patch new file mode 100644 index 0000000000000000000000000000000000000000..4090244f4d187ab8ae8be5396639b33660da8b20 --- /dev/null +++ b/libfdisk-script-fix-segmentation-fault.patch @@ -0,0 +1,33 @@ +From 3468dda9c34b1860d4b64f590651aab718b0cc5e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ga=C3=ABl=20PORTAY?= +Date: Fri, 20 Mar 2020 16:10:35 -0400 +Subject: [PATCH 151/389] libfdisk: (script) fix segmentation fault +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This patch fixes a segmentation fault that occurs if the name value is +empty (i.e. name=). + +Signed-off-by: Gaël PORTAY +--- + libfdisk/src/script.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c +index e73c8dc..cc53c3b 100644 +--- a/libfdisk/src/script.c ++++ b/libfdisk/src/script.c +@@ -1059,7 +1059,8 @@ static int parse_line_nameval(struct fdisk_script *dp, char *s) + } else if (!strncasecmp(p, "name=", 5)) { + p += 5; + rc = next_string(&p, &pa->name); +- unhexmangle_string(pa->name); ++ if (!rc) ++ unhexmangle_string(pa->name); + + } else if (!strncasecmp(p, "type=", 5) || + !strncasecmp(p, "Id=", 3)) { /* backward compatibility */ +-- +1.8.3.1 + diff --git a/libmount-use-mnt_stat_mountpoint-on-more-places.patch b/libmount-use-mnt_stat_mountpoint-on-more-places.patch new file mode 100644 index 0000000000000000000000000000000000000000..867e426d01537add2e7dee8b48e65e706380f5cc --- /dev/null +++ b/libmount-use-mnt_stat_mountpoint-on-more-places.patch @@ -0,0 +1,83 @@ +From 3168ba091f2b0cbd85253440ef11d27b46f34380 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 6 Apr 2020 11:58:29 +0200 +Subject: [PATCH 190/389] libmount: use mnt_stat_mountpoint() on more places + +Signed-off-by: Karel Zak +--- + libmount/src/context_mount.c | 8 ++++---- + libmount/src/mountP.h | 1 + + libmount/src/utils.c | 10 ++++++++++ + 3 files changed, 15 insertions(+), 4 deletions(-) + +diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c +index efd7050..ff7ee69 100644 +--- a/libmount/src/context_mount.c ++++ b/libmount/src/context_mount.c +@@ -1757,7 +1757,7 @@ int mnt_context_get_mount_excode( + if (!buf) + break; + if (geteuid() == 0) { +- if (stat(tgt, &st) || !S_ISDIR(st.st_mode)) ++ if (mnt_stat_mountpoint(tgt, &st) || !S_ISDIR(st.st_mode)) + snprintf(buf, bufsz, _("mount point is not a directory")); + else + snprintf(buf, bufsz, _("permission denied")); +@@ -1783,10 +1783,10 @@ int mnt_context_get_mount_excode( + snprintf(buf, bufsz, _("%s already mounted or mount point busy"), src); + break; + case ENOENT: +- if (tgt && lstat(tgt, &st)) { ++ if (tgt && mnt_lstat_mountpoint(tgt, &st)) { + if (buf) + snprintf(buf, bufsz, _("mount point does not exist")); +- } else if (tgt && stat(tgt, &st)) { ++ } else if (tgt && mnt_stat_mountpoint(tgt, &st)) { + if (buf) + snprintf(buf, bufsz, _("mount point is a symbolic link to nowhere")); + } else if (src && stat(src, &st)) { +@@ -1801,7 +1801,7 @@ int mnt_context_get_mount_excode( + break; + + case ENOTDIR: +- if (stat(tgt, &st) || ! S_ISDIR(st.st_mode)) { ++ if (mnt_stat_mountpoint(tgt, &st) || ! S_ISDIR(st.st_mode)) { + if (buf) + snprintf(buf, bufsz, _("mount point is not a directory")); + } else if (src && stat(src, &st) && errno == ENOTDIR) { +diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h +index 9e7ad2b..d8ba0ab 100644 +--- a/libmount/src/mountP.h ++++ b/libmount/src/mountP.h +@@ -123,6 +123,7 @@ extern void mnt_free_filesystems(char **filesystems); + + extern char *mnt_get_kernel_cmdline_option(const char *name); + extern int mnt_stat_mountpoint(const char *target, struct stat *st); ++extern int mnt_lstat_mountpoint(const char *target, struct stat *st); + extern FILE *mnt_get_procfs_memstream(int fd, char **membuf); + + /* tab.c */ +diff --git a/libmount/src/utils.c b/libmount/src/utils.c +index ffbd0c1..77207e7 100644 +--- a/libmount/src/utils.c ++++ b/libmount/src/utils.c +@@ -133,6 +133,16 @@ int mnt_stat_mountpoint(const char *target, struct stat *st) + #endif + } + ++int mnt_lstat_mountpoint(const char *target, struct stat *st) ++{ ++#ifdef AT_NO_AUTOMOUNT ++ return fstatat(AT_FDCWD, target, st, AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW); ++#else ++ return lstat(target, st); ++#endif ++} ++ ++ + /* + * Note that the @target has to be an absolute path (so at least "/"). The + * @filename returns an allocated buffer with the last path component, for example: +-- +1.8.3.1 + diff --git a/libuuid-ensure-variable-is-initialized-cppcheck.patch b/libuuid-ensure-variable-is-initialized-cppcheck.patch new file mode 100644 index 0000000000000000000000000000000000000000..5e5a42c8bb1758ca36cfa07314c8e27c4ea8389e --- /dev/null +++ b/libuuid-ensure-variable-is-initialized-cppcheck.patch @@ -0,0 +1,48 @@ +From 3c92864ecd755286b8a743d8ac3388e67ae8598c Mon Sep 17 00:00:00 2001 +From: Sami Kerola +Date: Sat, 29 Feb 2020 08:51:53 +0000 +Subject: [PATCH 179/389] libuuid: ensure variable is initialized [cppcheck] + +This fix has a little bit of a feel of making a static analyzer to be happy +instead of real progress. If I read the preprocessor directives correctly +it should be impossible hit uninitialized variable. Then again if a bug +creeps into these ifdef's in that case it is nice to have robust code that +doesn't immediately go wrong. + + libuuid/src/gen_uuid.c:200:20: error: Uninitialized variable: a [uninitvar] + memcpy(node_id, a, 6); + ^ + libuuid/src/gen_uuid.c:197:8: error: Uninitialized variable: a [uninitvar] + if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5]) + ^ + +Signed-off-by: Sami Kerola +--- + libuuid/src/gen_uuid.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c +index 27c135d..69f9591 100644 +--- a/libuuid/src/gen_uuid.c ++++ b/libuuid/src/gen_uuid.c +@@ -136,7 +136,7 @@ static int get_node_id(unsigned char *node_id) + struct ifconf ifc; + char buf[1024]; + int n, i; +- unsigned char *a; ++ unsigned char *a = NULL; + #ifdef HAVE_NET_IF_DL_H + struct sockaddr_dl *sdlp; + #endif +@@ -194,7 +194,7 @@ static int get_node_id(unsigned char *node_id) + #endif /* HAVE_NET_IF_DL_H */ + #endif /* SIOCGENADDR */ + #endif /* SIOCGIFHWADDR */ +- if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5]) ++ if (a == NULL || (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])) + continue; + if (node_id) { + memcpy(node_id, a, 6); +-- +1.8.3.1 + diff --git a/lsblk-Fall-back-to-ID_SERIAL.patch b/lsblk-Fall-back-to-ID_SERIAL.patch new file mode 100644 index 0000000000000000000000000000000000000000..e895f9cb6810f034035b59d1cd73b55bce286b37 --- /dev/null +++ b/lsblk-Fall-back-to-ID_SERIAL.patch @@ -0,0 +1,57 @@ +From e81d0f80068086147434fa947a4f723c00318772 Mon Sep 17 00:00:00 2001 +From: Sven Wiltink +Date: Fri, 1 May 2020 16:35:40 +0200 +Subject: [PATCH 238/389] lsblk: Fall back to ID_SERIAL + +In some cases ID_SERIAL_SHORT isn't provided by libudev, but ID_SERIAL +is. An example of this are virtio devices. See the output of udevadm +info: +P: /devices/pci0000:00/0000:00:06.0/virtio2/block/vdb +N: vdb +S: disk/by-id/virtio-08491434ee711d3420e9 +S: disk/by-path/pci-0000:00:06.0 +S: disk/by-path/virtio-pci-0000:00:06.0 +E: DEVLINKS=/dev/disk/by-id/virtio-08491434ee711d3420e9 /dev/disk/by-path/pci-0000:00:06.0 /dev/disk/by-path/virtio-pci-0000:00:06.0 +E: DEVNAME=/dev/vdb +E: DEVPATH=/devices/pci0000:00/0000:00:06.0/virtio2/block/vdb +E: DEVTYPE=disk +E: ID_PATH=pci-0000:00:06.0 +E: ID_PATH_TAG=pci-0000_00_06_0 +E: ID_SERIAL=08491434ee711d3420e9 +E: MAJOR=252 +E: MINOR=16 +E: SUBSYSTEM=block +E: TAGS=:systemd: +E: USEC_INITIALIZED=1403804 + +[kzak@redhat.com: - add ID_SERIAL also to get_properties_by_file()] + +Signed-off-by: Karel Zak +--- + misc-utils/lsblk-properties.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/misc-utils/lsblk-properties.c b/misc-utils/lsblk-properties.c +index 6f41eac..9e79be3 100644 +--- a/misc-utils/lsblk-properties.c ++++ b/misc-utils/lsblk-properties.c +@@ -107,6 +107,8 @@ static struct lsblk_devprop *get_properties_by_udev(struct lsblk_device *ld) + data = udev_device_get_property_value(dev, "ID_SCSI_SERIAL"); + if(!data) + data = udev_device_get_property_value(dev, "ID_SERIAL_SHORT"); ++ if(!data) ++ data = udev_device_get_property_value(dev, "ID_SERIAL"); + if (data) + prop->serial = xstrdup(data); + +@@ -209,6 +211,7 @@ static struct lsblk_devprop *get_properties_by_file(struct lsblk_device *ld) + else if (lookup(buf, "ID_WWN", &prop->wwn)) ; + else if (lookup(buf, "ID_SCSI_SERIAL", &prop->serial)) ; + else if (lookup(buf, "ID_SERIAL_SHORT", &prop->serial)) ; ++ else if (lookup(buf, "ID_SERIAL", &prop->serial)) ; + + /* lsblk specific */ + else if (lookup(buf, "MODE", &prop->mode)) ; +-- +1.8.3.1 + diff --git a/lscpu-fix-SIGSEGV-on-archs-without-drawers-books.patch b/lscpu-fix-SIGSEGV-on-archs-without-drawers-books.patch new file mode 100644 index 0000000000000000000000000000000000000000..1a9ce0632d4258d54316971e32135649e2b5bd13 --- /dev/null +++ b/lscpu-fix-SIGSEGV-on-archs-without-drawers-books.patch @@ -0,0 +1,89 @@ +From bdda3543142f20a8801f74986ba22104f960c7fa Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 17 Feb 2020 13:13:11 +0100 +Subject: [PATCH 046/389] lscpu: fix SIGSEGV on archs without drawers & books +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The drawers and books are optional and not supported on all +architectures and in this case drawers/books relevant arrays are not +allocated, so don't access it although user wants it +(e.g.  "lscpu -p -y --output-all"). + +This patch also cleans up arrays allocation to make it more readable +and robust against edit mistakes. + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1801760 +Signed-off-by: Karel Zak +--- + sys-utils/lscpu.c | 18 +++++++++++++----- + 1 file changed, 13 insertions(+), 5 deletions(-) + +diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c +index c1ccbb8..636d810 100644 +--- a/sys-utils/lscpu.c ++++ b/sys-utils/lscpu.c +@@ -1154,13 +1154,15 @@ read_topology(struct lscpu_desc *desc, int idx) + */ + desc->coremaps = xcalloc(desc->ncpuspos, sizeof(cpu_set_t *)); + desc->socketmaps = xcalloc(desc->ncpuspos, sizeof(cpu_set_t *)); +- desc->coreids = xcalloc(desc->ncpuspos, sizeof(*desc->drawerids)); +- desc->socketids = xcalloc(desc->ncpuspos, sizeof(*desc->drawerids)); ++ desc->coreids = xcalloc(desc->ncpuspos, sizeof(*desc->coreids)); ++ desc->socketids = xcalloc(desc->ncpuspos, sizeof(*desc->socketids)); ++ + for (i = 0; i < desc->ncpuspos; i++) + desc->coreids[i] = desc->socketids[i] = -1; ++ + if (book_siblings) { + desc->bookmaps = xcalloc(desc->ncpuspos, sizeof(cpu_set_t *)); +- desc->bookids = xcalloc(desc->ncpuspos, sizeof(*desc->drawerids)); ++ desc->bookids = xcalloc(desc->ncpuspos, sizeof(*desc->bookids)); + for (i = 0; i < desc->ncpuspos; i++) + desc->bookids[i] = -1; + } +@@ -1176,11 +1178,12 @@ read_topology(struct lscpu_desc *desc, int idx) + desc->coreids[idx] = coreid; + add_cpuset_to_array(desc->coremaps, &desc->ncores, thread_siblings); + desc->socketids[idx] = socketid; +- if (book_siblings) { ++ ++ if (book_siblings && desc->bookmaps && desc->bookids) { + add_cpuset_to_array(desc->bookmaps, &desc->nbooks, book_siblings); + desc->bookids[idx] = bookid; + } +- if (drawer_siblings) { ++ if (drawer_siblings && desc->drawermaps && desc->drawerids) { + add_cpuset_to_array(desc->drawermaps, &desc->ndrawers, drawer_siblings); + desc->drawerids[idx] = drawerid; + } +@@ -1509,6 +1512,8 @@ get_cell_data(struct lscpu_desc *desc, int idx, int col, + snprintf(buf, bufsz, "%d", desc->idx2nodenum[i]); + break; + case COL_CPU_DRAWER: ++ if (!desc->drawerids || !desc->drawermaps) ++ break; + if (mod->physical) { + if (desc->drawerids[idx] == -1) + snprintf(buf, bufsz, "-"); +@@ -1521,6 +1526,8 @@ get_cell_data(struct lscpu_desc *desc, int idx, int col, + } + break; + case COL_CPU_BOOK: ++ if (!desc->bookids || !desc->bookmaps) ++ break; + if (mod->physical) { + if (desc->bookids[idx] == -1) + snprintf(buf, bufsz, "-"); +@@ -1843,6 +1850,7 @@ print_cpus_parsable(struct lscpu_desc *desc, int cols[], int ncols, + data = get_cell_data(desc, i, cols[c], mod, + buf, sizeof(buf)); + fputs(data && *data ? data : "", stdout); ++ *buf = '\0'; + } + putchar('\n'); + } +-- +1.8.3.1 + diff --git a/script-fix-minor-warning.patch b/script-fix-minor-warning.patch new file mode 100644 index 0000000000000000000000000000000000000000..194f55a73763fae3c4b800896f3af8a214b4a397 --- /dev/null +++ b/script-fix-minor-warning.patch @@ -0,0 +1,31 @@ +From 9565786cb0f7d43c1228195859cc774282a5d27a Mon Sep 17 00:00:00 2001 +From: Sami Kerola +Date: Thu, 13 Feb 2020 20:47:51 +0000 +Subject: [PATCH 042/389] script: fix minor warning +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +ICO C does not allow extra ‘;’ outside of a function [-Wpedantic] + +Signed-off-by: Sami Kerola +--- + term-utils/script-playutils.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/term-utils/script-playutils.c b/term-utils/script-playutils.c +index 78f4d20..517c42d 100644 +--- a/term-utils/script-playutils.c ++++ b/term-utils/script-playutils.c +@@ -98,7 +98,7 @@ static inline void timerinc(struct timeval *a, struct timeval *b) + timeradd(a, b, &res); + a->tv_sec = res.tv_sec; + a->tv_usec = res.tv_usec; +-}; ++} + + struct replay_setup *replay_new_setup(void) + { +-- +1.8.3.1 + diff --git a/sfdisk-fix-ref-counting-for-the-script.patch b/sfdisk-fix-ref-counting-for-the-script.patch new file mode 100644 index 0000000000000000000000000000000000000000..f2a07155846482ddf80bec8110572abc639ef60c --- /dev/null +++ b/sfdisk-fix-ref-counting-for-the-script.patch @@ -0,0 +1,25 @@ +From da0debad5355fa39c30c9c4de73a19724de6e4b6 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 4 Feb 2020 15:54:53 +0100 +Subject: [PATCH 023/389] sfdisk: fix ref-counting for the script + +Signed-off-by: Karel Zak +--- + disk-utils/sfdisk.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c +index e08862a..1c5160c 100644 +--- a/disk-utils/sfdisk.c ++++ b/disk-utils/sfdisk.c +@@ -1951,6 +1951,7 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv) + break; + } + ++ fdisk_set_script(sf->cxt, NULL); + fdisk_unref_script(dp); + return rc; + } +-- +1.8.3.1 + diff --git a/sfdisk-only-report-I-O-errors-on-move-data.patch b/sfdisk-only-report-I-O-errors-on-move-data.patch new file mode 100644 index 0000000000000000000000000000000000000000..d580f3b77ac350ed2e8d8dd5e516dcdaac0deee3 --- /dev/null +++ b/sfdisk-only-report-I-O-errors-on-move-data.patch @@ -0,0 +1,134 @@ +From 79ef974a68d4e70b1ad69a18d70d8a04c9d00bd5 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 22 Apr 2020 14:57:33 +0200 +Subject: [PATCH 228/389] sfdisk: only report I/O errors on --move-data + +Now sfdisk stops everything on I/O error when moving data. It seems +better to report the error to user and continue as it's better to have +one bad sector in the partition than inconsistent all partition. + +Addresses: https://github.com/karelzak/util-linux/issues/984 +Signed-off-by: Karel Zak +--- + disk-utils/sfdisk.c | 58 ++++++++++++++++++++++++++++------------------------- + 1 file changed, 31 insertions(+), 27 deletions(-) + +diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c +index 24d1f72..07e8b23 100644 +--- a/disk-utils/sfdisk.c ++++ b/disk-utils/sfdisk.c +@@ -376,9 +376,9 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa + FILE *f = NULL; + int ok = 0, fd, backward = 0; + fdisk_sector_t nsectors, from, to, step, i, prev; +- size_t io, ss, step_bytes, cc; ++ size_t io, ss, step_bytes, cc, ioerr = 0; + uintmax_t src, dst, nbytes; +- int errsv, progress = 0; ++ int progress = 0, rc = 0; + struct timeval prev_time; + uint64_t bytes_per_sec = 0; + +@@ -474,8 +474,9 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa + if (typescript) { + f = fopen(typescript, "w"); + if (!f) { ++ rc = -errno; + fdisk_warn(sf->cxt, _("cannot open %s"), typescript); +- goto fail; ++ goto done; + } + + /* don't translate */ +@@ -506,8 +507,6 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa + prev = 0; + + for (cc = 1, i = 0; i < nsectors && nbytes > 0; i += step, cc++) { +- ssize_t rc; +- + if (backward) + src -= step_bytes, dst -= step_bytes; + +@@ -522,18 +521,26 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa + + if (!sf->noact) { + /* read source */ +- if (lseek(fd, src, SEEK_SET) == (off_t) -1) +- goto fail; +- rc = read(fd, buf, step_bytes); +- if (rc < 0 || rc != (ssize_t) step_bytes) +- goto fail; ++ if (lseek(fd, src, SEEK_SET) == (off_t) -1 || ++ read_all(fd, buf, step_bytes) != (ssize_t) step_bytes) { ++ if (f) ++ fprintf(f, "%05zu: read error %12ju %12ju\n", cc, src, dst); ++ fdisk_warn(sf->cxt, ++ _("cannot read at offset: %zu; continue"), src); ++ ioerr++; ++ goto next; ++ } + + /* write target */ +- if (lseek(fd, dst, SEEK_SET) == (off_t) -1) +- goto fail; +- rc = write(fd, buf, step_bytes); +- if (rc < 0 || rc != (ssize_t) step_bytes) +- goto fail; ++ if (lseek(fd, dst, SEEK_SET) == (off_t) -1 || ++ write_all(fd, buf, step_bytes) != 0) { ++ if (f) ++ fprintf(f, "%05zu: write error %12ju %12ju\n", cc, src, dst); ++ fdisk_warn(sf->cxt, ++ _("cannot write at offset: %zu; continue"), dst); ++ ioerr++; ++ goto next; ++ } + if (sf->movefsync) + fsync(fd); + } +@@ -571,7 +578,7 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa + fputc('\r', stdout); + + } +- ++next: + if (!backward) + src += step_bytes, dst += step_bytes; + } +@@ -587,6 +594,8 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa + 100.0 / ((double) nsectors/(i+1))); + fputc('\n', stdout); + } ++ rc = 0; ++done: + if (f) + fclose(f); + free(buf); +@@ -595,18 +604,13 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa + + if (sf->noact) + fdisk_info(sf->cxt, _("Your data has not been moved (--no-act).")); ++ if (ioerr) { ++ fdisk_info(sf->cxt, _("%zu I/O errors detected!"), ioerr); ++ rc = -EIO; ++ } else if (rc) ++ warn(_("%s: failed to move data"), devname); + +- return 0; +-fail: +- errsv = -errno; +- warn(_("%s: failed to move data"), devname); +- if (f) +- fclose(f); +- free(buf); +- free(devname); +- free(typescript); +- +- return errsv; ++ return rc; + } + + static int write_changes(struct sfdisk *sf) +-- +1.8.3.1 + diff --git a/tests-Fix-for-misc-fallocate-test-build-failure.patch b/tests-Fix-for-misc-fallocate-test-build-failure.patch new file mode 100644 index 0000000000000000000000000000000000000000..b89182afa3ff733cd10a1ae75339b117cab72e0f --- /dev/null +++ b/tests-Fix-for-misc-fallocate-test-build-failure.patch @@ -0,0 +1,32 @@ +From 89547e4767a975a8a0b08393a7ea4c7645bc96ef Mon Sep 17 00:00:00 2001 +From: Mark Hindley +Date: Tue, 5 May 2020 21:28:55 +0200 +Subject: tests: Fix for misc/fallocate test build failure. + +This was already a known possible failure case. However, in the migration to a +clearer separation of stdout and stderr in the testsuite, the logfile used to +detect the failure was not updated. + +Signed-off-by: Mark Hindley +--- + tests/ts/misc/fallocate | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +(limited to 'tests/ts/misc/fallocate') + +diff --git a/tests/ts/misc/fallocate b/tests/ts/misc/fallocate +index 2f77ee928..ec3d2d2f8 100755 +--- a/tests/ts/misc/fallocate ++++ b/tests/ts/misc/fallocate +@@ -30,7 +30,7 @@ else + # fs type of $TS_OUTDIR, could be used to skip this test early + fs_type=$(${TS_CMD_FINDMNT} -n -o FSTYPE -T ${TS_OUTDIR}) + +- grep -qi "fallocate: fallocate failed:.*not supported" $TS_OUTPUT \ ++ grep -qi "fallocate: fallocate failed:.*not supported" $TS_ERRLOG \ + && ts_skip "'${fs_type}' not supported" + fi + +-- +cgit 1.2.3-1.el7 + diff --git a/umount-don-t-try-it-as-non-suid-if-not-found-mountin.patch b/umount-don-t-try-it-as-non-suid-if-not-found-mountin.patch new file mode 100644 index 0000000000000000000000000000000000000000..fa9fff33bad8d925671f67849ae61c22d34a0642 --- /dev/null +++ b/umount-don-t-try-it-as-non-suid-if-not-found-mountin.patch @@ -0,0 +1,31 @@ +From d5edb1003bf3f06c907ac5e3f342cef3e41bccf9 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 24 Feb 2020 13:02:09 +0100 +Subject: [PATCH 076/389] umount: don't try it as non-suid if not found + mountinfo entry + +Addresses: https://github.com/karelzak/util-linux/issues/961 +Signed-off-by: Karel Zak +--- + sys-utils/umount.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/sys-utils/umount.c b/sys-utils/umount.c +index 74d87d6..056ffb8 100644 +--- a/sys-utils/umount.c ++++ b/sys-utils/umount.c +@@ -223,8 +223,10 @@ static int umount_one(struct libmnt_context *cxt, const char *spec) + + if (rc == -EPERM + && mnt_context_is_restricted(cxt) ++ && mnt_context_tab_applied(cxt) + && !mnt_context_syscall_called(cxt)) { +- /* Failed somewhere in libmount, drop perms and try it again */ ++ /* Mountpoint exists, but failed something else in libmount, ++ * drop perms and try it again */ + suid_drop(cxt); + rc = mnt_context_umount(cxt); + } +-- +1.8.3.1 + diff --git a/util-linux.spec b/util-linux.spec index 9d82301a0ecd622ea3579745f5069c7dfecfae88..3d48e59ee7aaa72959707b0a65ab79d4219327f2 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -2,7 +2,7 @@ Name: util-linux Version: 2.35.1 -Release: 1 +Release: 2 Summary: A random collection of Linux utilities License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain URL: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git @@ -25,19 +25,48 @@ Requires: pam >= 1.1.3-7, /etc/pam.d/system-auth audit-libs >= 1.0.6 Requires: libblkid = %{version}-%{release} libmount = %{version}-%{release} libsmartcols = %{version}-%{release} Requires: libfdisk = %{version}-%{release} libuuid = %{version}-%{release} -Conflicts: initscripts < 9.79-4 bash-completion < 1:2.1-1 coreutils < 8.20 sysvinit-tools < 2.88-14 +Conflicts: initscripts < 9.79-4 bash-completion < 1:2.1-1 coreutils < 8.20 Conflicts: e2fsprogs < 1.41.8-5 filesystem < 3 Provides: eject = 2.1.6 rfkill = 0.5 Provides: util-linux-ng = %{version}-%{release} Provides: /bin/dmesg /bin/kill /bin/more /bin/mount /bin/umount /sbin/blkid Provides: /sbin/blockdev /sbin/findfs /sbin/fsck /sbin/nologin -Obsoletes: eject <= 2.1.5 rfkill <= 0.5 util-linux-ng < 2.19 - -Patch0000: 2.28-login-lastlog-create.patch -Patch0001: libmount-move-already-mounted-code-to-separate-funct.patch -Patch0002: libmount-try-read-only-mount-on-write-protected-supe.patch -Patch0003: lscpu-use-official-name-for-HiSilicon-tsv110.patch +Obsoletes: eject <= 2.1.5 rfkill <= 0.5 util-linux-ng < 2.19 sysvinit-tools < 0:2.89 + +Patch0: 2.28-login-lastlog-create.patch +Patch1: libmount-move-already-mounted-code-to-separate-funct.patch +Patch2: libmount-try-read-only-mount-on-write-protected-supe.patch +Patch3: lscpu-use-official-name-for-HiSilicon-tsv110.patch +Patch4: Fix-off-by-one-when-checking-dev-mapper-path.patch +Patch5: cal-Correctly-center-the-year.patch +Patch6: cal-correctly-set-the-week-width.patch +Patch7: clang-tidy-use-ceil.patch +Patch8: findmnt-make-xalloc-use-mroe-robust.patch +Patch9: fsck.cramfs-fix-macro-usage.patch +Patch10: hwclock-fix-audit-exit-status.patch +Patch11: kill-include-sys-types.h-before-checking-SYS_pidfd_s.patch +Patch12: lib-mangle-check-for-the-NULL-string-argument.patch +Patch13: lib-strutils-fix-floating-point-exception.patch +Patch14: libfdisk-fix-alignment-logic-for-tiny-partitions.patch +Patch15: tests-Fix-for-misc-fallocate-test-build-failure.patch +Patch16: libfdisk-fix-partition-calculation-for-BLKPG_-ioctls.patch +Patch17: libfdisk-make-sure-we-check-for-maximal-number-of-pa.patch +Patch18: libfdisk-remove-unwanted-assert.patch +Patch19: libfdisk-script-accept-sector-size-ignore-unknown-he.patch +Patch20: libfdisk-script-fix-memory-leak.patch +Patch21: libfdisk-script-fix-partno_from_devname.patch +Patch22: libfdisk-script-fix-segmentation-fault.patch +Patch23: libmount-use-mnt_stat_mountpoint-on-more-places.patch +Patch24: libuuid-ensure-variable-is-initialized-cppcheck.patch +Patch25: lsblk-Fall-back-to-ID_SERIAL.patch +Patch26: lscpu-fix-SIGSEGV-on-archs-without-drawers-books.patch +Patch27: script-fix-minor-warning.patch +Patch28: sfdisk-fix-ref-counting-for-the-script.patch +Patch29: sfdisk-only-report-I-O-errors-on-move-data.patch +Patch30: umount-don-t-try-it-as-non-suid-if-not-found-mountin.patch +Patch31: write-fix-potential-string-overflow.patch +Patch32: do-not-excute-mountpoint-test.patch %description The util-linux package contains a random collection of files that @@ -287,6 +316,7 @@ fi %attr(4755,root,root) %{_bindir}/su %attr(755,root,root) %{_bindir}/login %attr(2755,root,tty) %{_bindir}/write +%attr(2555,root,tty) %{_bindir}/wall %ghost %attr(0644,root,root) %verify(not md5 size mtime) /var/log/lastlog %ghost %verify(not md5 size mtime) %config(noreplace,missingok) /etc/mtab %{_unitdir}/fstrim.* @@ -294,7 +324,7 @@ fi %{_bindir}/{flock,getopt,hexdump,ionice,ipcmk,ipcrm,ipcs,isosize,kill,last,lastb,logger,hardlink} %{_bindir}/{look,lsblk,lscpu,lsipc,lslocks,lslogins,lsmem,lsns,mcookie,mesg,more,mountpoint} %{_bindir}/{namei,nsenter,prlimit,raw,rename,renice,rev,script,scriptreplay,setarch,setpriv} -%{_bindir}/{setsid,setterm,taskset,ul,unshare,utmpdump,uuidgen,uuidparse,wall,wdctl,whereis,scriptlive} +%{_bindir}/{setsid,setterm,taskset,ul,unshare,utmpdump,uuidgen,uuidparse,wdctl,whereis,scriptlive} %{_sbindir}/{addpart,agetty,blkdiscard,blkid,blkzone,blockdev,chcpu,ctrlaltdel,delpart,fdisk} %{_sbindir}/{findfs,fsck,fsck.cramfs,fsck.minix,fsfreeze,fstrim,ldattach,losetup,mkfs,mkfs.cramfs} %{_sbindir}/{mkfs.minix,mkswap,nologin,partx,pivot_root,readprofile,resizepart,rfkill,rtcwake} @@ -381,6 +411,9 @@ fi %{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*} %changelog +* Wed Jul 1 2020 liuchengaung - 2.35.1-2 +- quality enhancement synchronization github patch + * Mon May 11 2020 openEuler Buildteam - 2.35.1-1 - Type:requirement - ID:NA diff --git a/write-fix-potential-string-overflow.patch b/write-fix-potential-string-overflow.patch new file mode 100644 index 0000000000000000000000000000000000000000..1eb12010c2350d0201ed4d034ce33ad77c0eab7a --- /dev/null +++ b/write-fix-potential-string-overflow.patch @@ -0,0 +1,41 @@ +From cdf84bf65804873708b2b76551d64116123ac128 Mon Sep 17 00:00:00 2001 +From: Sami Kerola +Date: Sat, 8 Feb 2020 21:12:14 +0000 +Subject: [PATCH 038/389] write: fix potential string overflow +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Noticed when compiled with gcc verion 9.2.1 20200130. + +term-utils/write.c:182:7: warning: ‘strcmp’ argument 1 declared attribute + ‘nonstring’ [-Wstringop-overflow=] + 182 | if (strcmp(u->ut_line, ctl->src_tty_name) == 0) { + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In file included from /usr/include/utmpx.h:31, + from term-utils/write.c:60: +/usr/include/bits/utmpx.h:59:8: note: argument ‘ut_line’ declared here + 59 | char ut_line[__UT_LINESIZE] + | ^~~~~~~ + +Signed-off-by: Sami Kerola +--- + term-utils/write.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/term-utils/write.c b/term-utils/write.c +index 3436fbd..90eb18c 100644 +--- a/term-utils/write.c ++++ b/term-utils/write.c +@@ -179,7 +179,7 @@ static void search_utmp(struct write_control *ctl) + if (ctl->src_uid && !tty_writeable) + /* skip ttys with msgs off */ + continue; +- if (strcmp(u->ut_line, ctl->src_tty_name) == 0) { ++ if (memcmp(u->ut_line, ctl->src_tty_name, strlen(ctl->src_tty_name) + 1) == 0) { + user_is_me = 1; + /* don't write to yourself */ + continue; +-- +1.8.3.1 +