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