From 005ec8901c94a42b78e1f342f94b2b64bd977933 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Wed, 22 Sep 2010 00:33:49 -0600 Subject: [PATCH] patch from upstream to fix mixed file mode representation problem in rmt --- debian/changelog | 6 ++-- rmt/rmt.c | 81 ++++++++++++++++++++++++++++++------------------ 2 files changed, 54 insertions(+), 33 deletions(-) diff --git a/debian/changelog b/debian/changelog index 65b8bee..9c9e6f7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,12 @@ -tar (1.23-3) UNRELEASED; urgency=low +tar (1.23-3) UNRELEASED; urgency=medium * add xz-utils back to the Suggests list since it may not be 'required' forever * current debhelper includes trigger support, closes: #561598 + * patch from upstream to fix ability of rmt to accept mixed file mode + representations, closes: #587702, #597672 - -- Bdale Garbee Tue, 15 Jun 2010 09:32:39 -0600 + -- Bdale Garbee Wed, 22 Sep 2010 00:33:16 -0600 tar (1.23-2.1) unstable; urgency=low diff --git a/rmt/rmt.c b/rmt/rmt.c index a3897eb..4932ae8 100644 --- a/rmt/rmt.c +++ b/rmt/rmt.c @@ -100,6 +100,7 @@ rmt_write (const char *fmt, ...) va_list ap; va_start (ap, fmt); vfprintf (stdout, fmt, ap); + fflush (stdout); VDEBUG (10, "S: ", fmt, ap); } @@ -117,6 +118,7 @@ rmt_error_message (int code, const char *msg) DEBUG1 (10, "S: %s\n", msg); DEBUG1 (1, "error: %s\n", msg); fprintf (stdout, "E%d\n%s\n", code, msg); + fflush (stdout); } void @@ -225,44 +227,57 @@ static struct rmt_kw const open_flag_kw[] = int decode_open_flag (const char *mstr, int *pmode) { + int numeric_mode = 0; int mode = 0; + const char *p; - while (mstr) + mstr = skip_ws (mstr); + if (c_isdigit (*mstr)) { - int v; - const char *p; - - mstr = skip_ws (mstr); - if (*mstr == 0) - break; - else if (c_isdigit (*mstr)) - v = strtol (mstr, (char**) &p, 10); - else if (xlat_kw (mstr, "O_", open_flag_kw, &v, &p)) - { - rmt_error_message (EINVAL, "invalid open mode"); - return 1; - } - - mode |= v; + numeric_mode = strtol (mstr, (char**) &p, 10); + mstr = skip_ws (p); + } - if (*p && c_isblank (*p)) - p = skip_ws (p); - if (*p == 0) - break; - else if (*p == '|') - { - /* FIXMEL - if (p[1] == 0) - rmt_error_message (EINVAL, "invalid open mode"); - */ - mstr = p + 1; - } - else + if (*mstr) + { + while (mstr) { - rmt_error_message (EINVAL, "invalid open mode"); - return 1; + int v; + + mstr = skip_ws (mstr); + if (*mstr == 0) + break; + else if (c_isdigit (*mstr)) + v = strtol (mstr, (char**) &p, 10); + else if (xlat_kw (mstr, "O_", open_flag_kw, &v, &p)) + { + rmt_error_message (EINVAL, "invalid open mode"); + return 1; + } + + mode |= v; + + if (*p && c_isblank (*p)) + p = skip_ws (p); + if (*p == 0) + break; + else if (*p == '|') + { + /* FIXMEL + if (p[1] == 0) + rmt_error_message (EINVAL, "invalid open mode"); + */ + mstr = p + 1; + } + else + { + rmt_error_message (EINVAL, "invalid open mode"); + return 1; + } } } + else + mode = numeric_mode; *pmode = mode; return 0; } @@ -288,6 +303,10 @@ decode_open_flag (const char *mstr, int *pmode) 64|512 CREAT|TRUNC + In addition, a compined form is also allowed, i.e. a decimal mode followed + by its symbolic representation. In this case the symbolic representation + is given preference. + Reply ----- A0\n on success, E\n\n on error. -- 2.43.0