diff -Nru util-linux-2.27.1/debian/changelog util-linux-2.27.1/debian/changelog --- util-linux-2.27.1/debian/changelog 2016-05-26 14:25:44.000000000 +0000 +++ util-linux-2.27.1/debian/changelog 2016-12-16 14:49:14.000000000 +0000 @@ -1,3 +1,10 @@ +util-linux (2.27.1-6ubuntu3.2) xenial; urgency=medium + + * Cherrypick upstream fix to prevent segfaults in getopt by ensuring + that options array is correctly terminated. LP: #1577460 + + -- Dimitri John Ledkov Fri, 16 Dec 2016 14:49:06 +0000 + util-linux (2.27.1-6ubuntu3.1) xenial; urgency=medium * debian/patches/git_hybrid_cds.patch: diff -Nru util-linux-2.27.1/debian/patches/e1164591f7927402af8d73d340e75dbfeb06a288.patch util-linux-2.27.1/debian/patches/e1164591f7927402af8d73d340e75dbfeb06a288.patch --- util-linux-2.27.1/debian/patches/e1164591f7927402af8d73d340e75dbfeb06a288.patch 1970-01-01 00:00:00.000000000 +0000 +++ util-linux-2.27.1/debian/patches/e1164591f7927402af8d73d340e75dbfeb06a288.patch 2016-12-16 14:48:50.000000000 +0000 @@ -0,0 +1,58 @@ +From e1164591f7927402af8d73d340e75dbfeb06a288 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Fri, 21 Oct 2016 13:51:48 +0200 +Subject: getopt: be sure that options array is terminated + +Reported-by: Anders Kaseorg +Signed-off-by: Karel Zak +--- + misc-utils/getopt.c | 19 +++++++++++-------- + 1 file changed, 11 insertions(+), 8 deletions(-) + +diff --git a/misc-utils/getopt.c b/misc-utils/getopt.c +index 01b5883..94cfec5 100644 +--- a/misc-utils/getopt.c ++++ b/misc-utils/getopt.c +@@ -253,6 +253,7 @@ static void __attribute__ ((__noreturn__)) parse_error(const char *message) + static void add_longopt(struct getopt_control *ctl, const char *name, int has_arg) + { + static int flag; ++ int nr = ctl->long_options_nr; + + if (ctl->long_options_nr == ctl->long_options_length) { + ctl->long_options_length += REALLOC_INCREMENT; +@@ -262,10 +263,16 @@ static void add_longopt(struct getopt_control *ctl, const char *name, int has_ar + } + if (name) { + /* Not for init! */ +- ctl->long_options[ctl->long_options_nr].has_arg = has_arg; +- ctl->long_options[ctl->long_options_nr].flag = &flag; +- ctl->long_options[ctl->long_options_nr].val = ctl->long_options_nr; +- ctl->long_options[ctl->long_options_nr].name = xstrdup(name); ++ ctl->long_options[nr].has_arg = has_arg; ++ ctl->long_options[nr].flag = &flag; ++ ctl->long_options[nr].val = ctl->long_options_nr; ++ ctl->long_options[nr].name = xstrdup(name); ++ } else { ++ /* lets use add_longopt(ct, NULL, 0) to terminate the array */ ++ ctl->long_options[nr].name = NULL; ++ ctl->long_options[nr].has_arg = 0; ++ ctl->long_options[nr].flag = NULL; ++ ctl->long_options[nr].val = 0; + } + } + +@@ -303,10 +310,6 @@ static void add_long_options(struct getopt_control *ctl, char *options) + tokptr = strtok(NULL, ", \t\n"); + } + add_longopt(ctl, NULL, 0); /* ensure long_options[] is not full */ +- ctl->long_options[ctl->long_options_nr].name = NULL; +- ctl->long_options[ctl->long_options_nr].has_arg = 0; +- ctl->long_options[ctl->long_options_nr].flag = NULL; +- ctl->long_options[ctl->long_options_nr].val = 0; + } + + static shell_t shell_type(const char *new_shell) +-- +cgit v0.12 + diff -Nru util-linux-2.27.1/debian/patches/series util-linux-2.27.1/debian/patches/series --- util-linux-2.27.1/debian/patches/series 2016-05-25 15:57:34.000000000 +0000 +++ util-linux-2.27.1/debian/patches/series 2016-12-16 14:48:50.000000000 +0000 @@ -9,3 +9,4 @@ sulogin-fallback-static-sh.patch sulogin-lockedpwd.patch git_hybrid_cds.patch +e1164591f7927402af8d73d340e75dbfeb06a288.patch