PennMUSH Community

Changeset 1044

Show
Ignore:
Timestamp:
07/10/07 13:15:46 (1 year ago)
Author:
shawnw
Message:

#7410: decode64() fix in trunk

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 1.8.3/trunk/src/funcrypt.c

    r1032 r1044  
    8787} 
    8888 
     89extern char valid_ansi_codes[UCHAR_MAX + 1]; 
     90 
    8991static bool 
    9092decode_base64(char *encoded, int len, char *buff, char **bp) 
     
    9294#ifdef HAVE_SSL 
    9395  BIO *bio, *b64, *bmem; 
    94   char *start, *sbp; 
     96  char *sbp; 
    9597 
    9698  b64 = BIO_new(BIO_f_base64()); 
     
    111113  bio = BIO_push(b64, bmem); 
    112114 
    113   start = buff; 
    114115  sbp = *bp; 
    115116  while (true) { 
    116117    char decoded[BUFFER_LEN]; 
    117118    int dlen; 
     119 
    118120    dlen = BIO_read(bio, decoded, BUFFER_LEN); 
    119     if (dlen > 0) 
     121    if (dlen > 0) { 
     122      int n; 
     123      for (n = 0; n < dlen; n++) { 
     124        if (decoded[n] == TAG_START) { 
     125          int end; 
     126          n += 1; 
     127          for (end = n; end < dlen; end++) { 
     128            if (decoded[end] == TAG_END) 
     129              break; 
     130          } 
     131          if (end == dlen || decoded[n] != MARKUP_COLOR) { 
     132            BIO_free_all(bio); 
     133            *bp = sbp; 
     134            safe_str(T("#-1 CONVERSION ERROR"), buff, bp); 
     135            return false; 
     136          } 
     137          for (; n < end; n++) { 
     138            if (!valid_ansi_codes[(unsigned char) decoded[n]]) { 
     139              BIO_free_all(bio); 
     140              *bp = sbp; 
     141              safe_str(T("#-1 CONVERSION ERROR"), buff, bp); 
     142              return false; 
     143            } 
     144          } 
     145          n = end; 
     146        } else if (!isprint((unsigned char) decoded[n])) 
     147          decoded[n] = '?'; 
     148      } 
    120149      safe_strl(decoded, dlen, buff, bp); 
    121     else if (dlen == 0) 
     150    } else if (dlen == 0) 
    122151      break; 
    123152    else { 
    124       buff = start; 
    125153      *bp = sbp; 
    126154      safe_str(T("#-1 CONVERSION ERROR"), buff, bp); 
  • 1.8.3/trunk/src/tables.c

    r463 r1044  
    1 /* This file was generated by running ./gentables compiled from 
     1/* This file was generated by running ./a.out compiled from 
    22 * utils/gentables.c. Edit that file, not this one, when making changes. */ 
    33#include <stdlib.h> 
     
    8888  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    8989  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 
     90  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     91  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     92  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     93  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     94  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     95  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     96  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     97  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 
     98}; 
     99 
     100char valid_ansi_codes[256] = { 
     101  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     102  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     103  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 
     104  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     105  0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 
     106  0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 
     107  0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 
     108  0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 
    90109  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    91110  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  • 1.8.3/trunk/utils/gentables.c

    r846 r1044  
    107107}; 
    108108   
     109 
     110/* Color codes used in ansi markup */ 
     111char ansi_codes[UCHAR_MAX + 1] = { 
     112  ['h'] = 1, ['i'] = 1, ['f'] = 1, ['u'] = 1, ['n'] = 1, 
     113  ['x'] = 1, ['r'] = 1, ['g'] = 1, ['y'] = 1, ['b'] = 1,  
     114  ['c'] = 1, ['m'] = 1, ['w'] = 1, 
     115  ['X'] = 1, ['R'] = 1, ['G'] = 1, ['Y'] = 1, ['B'] = 1,  
     116  ['C'] = 1, ['M'] = 1, ['W'] = 1, 
     117  ['/'] = 1, ['a'] = 1 
     118}; 
    109119 
    110120/** Accented characters  
     
    266276  print_table_bool("char", "valid_timefmt_codes", valid_timefmt_codes, 0); 
    267277  print_table_bool("char", "escaped_chars", escaped_chars, 0); 
     278  print_table_bool("char", "valid_ansi_codes", ansi_codes, 0); 
    268279  print_entity_table("accent_table", entity_table); 
    269280  return EXIT_SUCCESS;