Magellan Linux

Annotation of /trunk/util-linux/patches/util-linux-2.18-cfdisk-string-len.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1078 - (hide annotations) (download)
Tue Aug 17 15:39:36 2010 UTC (13 years, 9 months ago) by niro
File size: 1683 byte(s)
patches for 2.18

1 niro 1078 http://bugs.gentoo.org/328959
2    
3     From 54a0fe298b4d6d948cffbd6fbbbe7dbabc9a6bb1 Mon Sep 17 00:00:00 2001
4     From: Karel Zak <kzak@redhat.com>
5     Date: Mon, 19 Jul 2010 22:52:58 +0200
6     Subject: [PATCH] cfdisk: get_string not calculating correct limits
7    
8     Reported-by: James L. Hammons <jlhamm@acm.org>
9     Signed-off-by: Karel Zak <kzak@redhat.com>
10     ---
11     fdisk/cfdisk.c | 11 ++++++++---
12     1 files changed, 8 insertions(+), 3 deletions(-)
13    
14     diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c
15     index 7fa0b19..e7955fe 100644
16     --- a/fdisk/cfdisk.c
17     +++ b/fdisk/cfdisk.c
18     @@ -421,6 +421,11 @@ fdexit(int ret) {
19     exit(ret);
20     }
21    
22     +/*
23     + * Note that @len is size of @str buffer.
24     + *
25     + * Returns number of read bytes (without \0).
26     + */
27     static int
28     get_string(char *str, int len, char *def) {
29     size_t cells = 0, i = 0;
30     @@ -472,7 +477,7 @@ get_string(char *str, int len, char *def) {
31     break;
32     default:
33     #if defined(HAVE_LIBNCURSESW) && defined(HAVE_WIDECHAR)
34     - if (i < len && iswprint(c)) {
35     + if (i + 1 < len && iswprint(c)) {
36     wchar_t wc = (wchar_t) c;
37     char s[MB_CUR_MAX + 1];
38     int sz = wctomb(s, wc);
39     @@ -492,7 +497,7 @@ get_string(char *str, int len, char *def) {
40     putchar(BELL);
41     }
42     #else
43     - if (i < len && isprint(c)) {
44     + if (i + 1 < len && isprint(c)) {
45     mvaddch(y, x + cells, c);
46     if (use_def) {
47     clrtoeol();
48     @@ -2405,7 +2410,7 @@ change_id(int i) {
49    
50     sprintf(def, "%02X", new_id);
51     mvaddstr(COMMAND_LINE_Y, COMMAND_LINE_X, _("Enter filesystem type: "));
52     - if ((len = get_string(id, 2, def)) <= 0 && len != GS_DEFAULT)
53     + if ((len = get_string(id, 3, def)) <= 0 && len != GS_DEFAULT)
54     return;
55    
56     if (len != GS_DEFAULT) {
57     --
58     1.7.1.1
59