[dev] [st] Two flaws with ISO 8613-6 colors, continued

From: Programmer <programmer_AT_verisimilitudes.net>
Date: Fri, 13 Jul 2018 21:23:43 -0400

The following diff corrects the flaws I've mentioned earlier with
regards to ISO 8613-6 colors; to repeat, these flaws include not
permitting colons to be used as seperators and incorrectly parsing RGB
color parameters; only six lines are changed and changed very little at
that, but I'll still release these six changed lines to the public
domain, for simplicity:

diff -c /home/programmer/st-0.8.1/st.c\~ /home/programmer/st-0.8.1/st.c
*** /home/programmer/st-0.8.1/st.c~ Tue Mar 20 15:29:59 2018
--- /home/programmer/st-0.8.1/st.c Fri Jul 13 19:32:43 2018
***************
*** 1157,1163 ****
                          v = -1;
                  csiescseq.arg[csiescseq.narg++] = v;
                  p = np;
! if (*p != ';' || csiescseq.narg == ESC_ARG_SIZ)
                          break;
                  p++;
          }
--- 1157,1163 ----
                          v = -1;
                  csiescseq.arg[csiescseq.narg++] = v;
                  p = np;
! if (*p != ';' || *p != ':' || csiescseq.narg == ESC_ARG_SIZ)
                          break;
                  p++;
          }
***************
*** 1311,1326 ****

          switch (attr[*npar + 1]) {
          case 2: /* direct color in RGB space */
! if (*npar + 4 >= l) {
                          fprintf(stderr,
                                  "erresc(38): Incorrect number of parameters (%d)\n",
                                  *npar);
                          break;
                  }
! r = attr[*npar + 2];
! g = attr[*npar + 3];
! b = attr[*npar + 4];
! *npar += 4;
                  if (!BETWEEN(r, 0, 255) || !BETWEEN(g, 0, 255) || !BETWEEN(b, 0, 255))
                          fprintf(stderr, "erresc: bad rgb color (%u,%u,%u)\n",
                                  r, g, b);
--- 1311,1326 ----

          switch (attr[*npar + 1]) {
          case 2: /* direct color in RGB space */
! if (*npar + 5 >= l) {
                          fprintf(stderr,
                                  "erresc(38): Incorrect number of parameters (%d)\n",
                                  *npar);
                          break;
                  }
! r = attr[*npar + 3];
! g = attr[*npar + 4];
! b = attr[*npar + 5];
! *npar += 5;
                  if (!BETWEEN(r, 0, 255) || !BETWEEN(g, 0, 255) || !BETWEEN(b, 0, 255))
                          fprintf(stderr, "erresc: bad rgb color (%u,%u,%u)\n",
                                  r, g, b);

Diff finished. Fri Jul 13 19:33:32 2018
Received on Sat Jul 14 2018 - 03:23:43 CEST

This archive was generated by hypermail 2.3.0 : Sat Jul 14 2018 - 03:24:08 CEST