SPDX: license tags (mostly by guesswork)
[exim.git] / src / src / auths / xtextencode.c
index a27a6a44aa76db2dedbdd24b4943e7e5811e8274..89f12f1f1f9233d9d8fcbd5dc707a31a0b5e6400 100644 (file)
@@ -1,11 +1,11 @@
-/* $Cambridge: exim/src/src/auths/xtextencode.c,v 1.2 2005/01/04 10:00:43 ph10 Exp $ */
-
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2005 */
+/* Copyright (c) The Exim Maintainers 2022 */
+/* Copyright (c) University of Cambridge 1995 - 2018 */
 /* See the file NOTICE for conditions of use and distribution. */
+/* SPDX-License-Identifier: GPL-2.0-only */
 
 #include "../exim.h"
 
@@ -30,7 +30,7 @@ uschar *
 auth_xtextencode(uschar *clear, int len)
 {
 uschar *code;
-uschar *p = (uschar *)clear;
+uschar *p = US clear;
 uschar *pp;
 int c = len;
 int count = 1;
@@ -42,19 +42,15 @@ in order to get the right amount of store. */
 while (c -- > 0)
   count += ((x = *p++) < 33 || x > 127 || x == '+' || x == '=')? 3 : 1;
 
-pp = code = store_get(count);
+pp = code = store_get(count, clear);
 
-p = (uschar *)clear;
+p = US clear;
 c = len;
 while (c-- > 0)
-  {
   if ((x = *p++) < 33 || x > 127 || x == '+' || x == '=')
-    {
-    sprintf(CS pp, "+%.02x", x);   /* There's always room */
-    pp += 3;
-    }
-  else *pp++ = x;
-  }
+    pp += sprintf(CS pp, "+%.02x", x);   /* There's always room */
+  else
+    *pp++ = x;
 
 *pp = 0;
 return code;