* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#if HAVE_CONFIG_H
#include "iconvert.h"
#include "share/alloc.h"
+#include "share/safe_str.h"
/*
* Convert data from one encoding to another. Return:
tocode[4] != '8' ||
tocode[5] != '\0') {
char *tocode1;
-
+ size_t dest_len = strlen(tocode) + 11;
/*
* Try using this non-standard feature of glibc and libiconv.
* This is deliberately not a config option as people often
* change their iconv library without rebuilding applications.
*/
- tocode1 = safe_malloc_add_2op_(strlen(tocode), /*+*/11);
+ tocode1 = safe_malloc_(dest_len);
if (!tocode1)
goto fail;
- strcpy(tocode1, tocode);
- strcat(tocode1, "//TRANSLIT");
+ safe_strncpy(tocode1, tocode, dest_len);
+ safe_strncat(tocode1, "//TRANSLIT", dest_len);
cd2 = iconv_open(tocode1, "UTF-8");
free(tocode1);