]> granicus.if.org Git - procps-ng/commitdiff
watch: tolerate umlauts
authoralbert <>
Mon, 28 May 2007 03:18:52 +0000 (03:18 +0000)
committeralbert <>
Mon, 28 May 2007 03:18:52 +0000 (03:18 +0000)
NEWS
TODO
top.c
watch.c

diff --git a/NEWS b/NEWS
index 12c945a4d3f1b98560a63704ab3c7432c719c155..9de1b95982644737dff751a4b73460c3fc84e212 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ top: normal exit code should be 0          #341272 #354255
 pgrep: usage error should exit with 2       #413383
 vmstat: use EXIT_FAILURE -- thanks Yoshio Nakamura   #425492
 sysctl: fix crash -- thanks Steinar Gunderson      #423704
+watch: tolerate umlauts                          #207103
 
 procps-3.2.6 --> procps-3.2.7
 
diff --git a/TODO b/TODO
index 3a61258dc417484afaac568135bc97ad22d1af66..a3429262907fa42fb21dbe000a62406481107674 100644 (file)
--- a/TODO
+++ b/TODO
@@ -45,6 +45,8 @@ Tolerate color, bold, underline, etc. #129334
 
 Tolerate stderr.  #420377 #155227 #225549
 
+Tolerate VT100 line-drawing characters. Maybe translate them.
+
 ---------------------- w --------------------------
 
 The LOGIN@ column sometimes has a space in it. This makes correct
diff --git a/top.c b/top.c
index 19ddb0a96ded150985b531e3fddc48ccf77921fb..690252786be65d3d5c1fd75959138ebcb28e428e 100644 (file)
--- a/top.c
+++ b/top.c
@@ -654,9 +654,12 @@ static void show_special (int interact, const char *glob)
    while ((lin_end = strchr(glob, '\n'))) {
 
          /* create a local copy we can extend and otherwise abuse */
-      memcpy(lin, glob, (unsigned)(lin_end - glob));    FIXME -- buffer overflow
+      size_t amt = lin_end - glob;
+      if(amt > sizeof lin - 1)
+         amt = sizeof lin - 1;  // shit happens
+      memcpy(lin, glob, amt);
          /* zero terminate this part and prepare to parse substrings */
-      lin[lin_end - glob] = '\0';
+      lin[amt] = '\0';
       room = Screen_cols;
       sub_beg = sub_end = lin;
       *(rp = row) = '\0';
@@ -669,6 +672,9 @@ static void show_special (int interact, const char *glob)
                cap = Curwin->captab[(int)*sub_end];
                *sub_end = '\0';
                snprintf(tmp, sizeof(tmp), "%s%.*s%s", cap, room, sub_beg, Caps_off);
+               amt = strlen(tmp);
+               if(rp - tmp + amt + 1 > sizeof tmp)
+                  goto overflow;  // shit happens
                rp = scat(rp, tmp);
                room -= (sub_end - sub_beg);
                sub_beg = ++sub_end;
@@ -678,7 +684,7 @@ static void show_special (int interact, const char *glob)
          }
          if (unlikely(0 >= room)) break; /* skip substrings that won't fit */
       }
-
+overflow:
       if (interact) PUTT("%s%s\n", row, Cap_clr_eol);
       else PUFF("%s%s\n", row, Cap_clr_eol);
       glob = ++lin_end;                 /* point to next line (maybe) */
diff --git a/watch.c b/watch.c
index 7d7be933c9914bf1c7535c7dca70c6810a5aba96..584116853b7aca6ac165c9c51ca71ed4414ebfdb 100644 (file)
--- a/watch.c
+++ b/watch.c
@@ -296,10 +296,10 @@ main(int argc, char *argv[])
                                }
                                move(y, x);
                                if (option_differences) {
-                                       int oldch = inch();
+                                       chtype oldch = inch();
                                        char oldc = oldch & A_CHARTEXT;
                                        attr = !first_screen
-                                           && (c != oldc
+                                           && ((char)c != oldc
                                                ||
                                                (option_differences_cumulative
                                                 && (oldch & A_ATTRIBUTES)));