/* * detaint.c - make string untained * https://mta.org.ua/exim-4.94-conf/dlfunc/detaint/detaint.c * * Copyright (C) 2020-2023 Victor Ustugov * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include //#define DLFUNC_IMPL //#include "local_scan.h" //#include "macros.h" #include "exim.h" //# define string_copy(s) string_copy_function(s) //# define string_copyn(s, n) string_copyn_function((s), (n)) //# define string_copy_taint(s, t) string_copy_taint_function((s), (t)) extern uschar * string_copy_function(const uschar *); extern uschar * string_copyn_function(const uschar *, int n); extern uschar * string_copy_taint_function(const uschar *, BOOL tainted); int detaint(uschar **yield, int argc, uschar *argv[]) { uschar *p1; uschar *p2; int i; if (argc != 1) { *yield = string_copy(US"Invalid number of arguments"); return ERROR; } // *yield = string_copy_taint(argv[0], FALSE); *yield = store_get(Ustrlen(argv[0]) + 1, FALSE); p1 = argv[0]; p2 = *yield; for (i = 0; i < Ustrlen(argv[0]); i++) { *p2 = *p1; p1++; p2++; } *p2 = 0; return OK; }