Branch: Tag:

2001-08-29

2001-08-29 11:52:11 by Henrik Grubbström (Grubba) <grubba@grubba.org>

More string-builder NUL-termination fixes. Fixes [bug 2034 (#2034)].

Rev: src/stralloc.c:1.119

26:   #define HUGE HUGE_VAL   #endif /*!HUGE*/    - RCSID("$Id: stralloc.c,v 1.118 2001/07/04 00:03:02 hubbe Exp $"); + RCSID("$Id: stralloc.c,v 1.119 2001/08/29 11:52:11 grubba Exp $");      #define BEGIN_HASH_SIZE 997   #define MAX_AVG_LINK_LENGTH 3
1825:    }    i = s->s->len++;    low_set_index(s->s,i,ch); +  /* Ensure NUL-termination */ +  s->s->str[s->s->len << s->s->size_shift] = 0;   }      
1840:    fatal("Illegal magnitude!\n");    }    s->s->len+=len; +  /* Ensure NUL-termination */ +  s->s->str[s->s->len << s->s->size_shift] = 0;   }      
1858:    string_build_mkspace(s, len, shift);    generic_memcpy(MKPCHARP_STR_OFF(s->s,s->s->len), from, len);    s->s->len+=len; +  /* Ensure NUL-termination */ +  s->s->str[s->s->len << s->s->size_shift] = 0;   }      PMOD_EXPORT void string_builder_fill(struct string_builder *s,
1882:    MEMSET(string_builder_allocate(s,howmany,0),    EXTRACT_PCHARP(from),    howmany); +  /* Ensure NUL-termination */ +  s->s->str[s->s->len << s->s->size_shift] = 0;    return;    }   
1924:    s->s->len+=tmp;    }    } +  /* Ensure NUL-termination */ +  s->s->str[s->s->len << s->s->size_shift] = 0;   }      PMOD_EXPORT void string_builder_strcat(struct string_builder *s, char *str)
1938:    pike_string_cpy(MKPCHARP_STR_OFF(s->s,s->s->len), str);    s->known_shift=MAXIMUM(s->known_shift,(size_t)str->size_shift);    s->s->len+=str->len; +  /* Ensure NUL-termination */ +  s->s->str[s->s->len << s->s->size_shift] = 0;   }      
1945:   {    s->known_shift=0;    s->s->len=0; +  /* Ensure NUL-termination */ +  s->s->str[0] = 0;   }      PMOD_EXPORT void free_string_builder(struct string_builder *s)
1955:      PMOD_EXPORT struct pike_string *finish_string_builder(struct string_builder *s)   { +  /* Ensure NUL-termination */    low_set_index(s->s,s->s->len,0);    if (s->s->len <= SHORT_STRING_THRESHOLD) {    ptrdiff_t len = s->s->len;