~ubuntu-branches/ubuntu/quantal/flac/quantal

« back to all changes in this revision

Viewing changes to src/share/utf8/iconvert.c

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-12-06 16:57:20 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20071206165720-ldii5tm8dq6zxg0l
Tags: 1.2.1-1ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/control: xmms-dev dropped to allow xmms to move to universe,
    adjust maintainer field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <stdlib.h>
29
29
#include <string.h>
30
30
 
 
31
#include "iconvert.h"
 
32
#include "share/alloc.h"
 
33
 
31
34
/*
32
35
 * Convert data from one encoding to another. Return:
33
36
 *
79
82
     * This is deliberately not a config option as people often
80
83
     * change their iconv library without rebuilding applications.
81
84
     */
82
 
    tocode1 = (char *)malloc(strlen(tocode) + 11);
 
85
    tocode1 = (char *)safe_malloc_add_2op_(strlen(tocode), /*+*/11);
83
86
    if (!tocode1)
84
87
      goto fail;
85
88
 
117
120
      break;
118
121
    if (obl < 6) {
119
122
      /* Enlarge the buffer */
 
123
      if(utflen*2 < utflen) /* overflow check */
 
124
        goto fail;
120
125
      utflen *= 2;
121
126
      newbuf = (char *)realloc(utfbuf, utflen);
122
127
      if (!newbuf)
143
148
      iconv_close(cd1);
144
149
      return ret;
145
150
    }
146
 
    newbuf = (char *)realloc(utfbuf, (ob - utfbuf) + 1);
 
151
    newbuf = (char *)safe_realloc_add_2op_(utfbuf, (ob - utfbuf), /*+*/1);
147
152
    if (!newbuf)
148
153
      goto fail;
149
154
    ob = (ob - utfbuf) + newbuf;
194
199
  outlen += ob - tbuf;
195
200
 
196
201
  /* Convert from UTF-8 for real */
197
 
  outbuf = (char *)malloc(outlen + 1);
 
202
  outbuf = (char *)safe_malloc_add_2op_(outlen, /*+*/1);
198
203
  if (!outbuf)
199
204
    goto fail;
200
205
  ib = utfbuf;