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