Просмотр исходного кода

check_smtp: Fix strcat overflows

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Anders Kaseorg 13 лет назад
Родитель
Сommit
638b596992
1 измененных файлов с 2 добавлено и 4 удалено
  1. 2 4
      plugins/check_smtp.c

+ 2 - 4
plugins/check_smtp.c

@@ -366,8 +366,7 @@ main (int argc, char **argv)
 
 
 					/* encode authuser with base64 */
 					/* encode authuser with base64 */
 					base64_encode_alloc (authuser, strlen(authuser), &abuf);
 					base64_encode_alloc (authuser, strlen(authuser), &abuf);
-					/* FIXME: abuf shouldn't have enough space to strcat a '\r\n' into it. */
-					strcat (abuf, "\r\n");
+					xasprintf(&abuf, "%s\r\n", abuf);
 					my_send(abuf, strlen(abuf));
 					my_send(abuf, strlen(abuf));
 					if (verbose)
 					if (verbose)
 						printf (_("sent %s\n"), abuf);
 						printf (_("sent %s\n"), abuf);
@@ -387,8 +386,7 @@ main (int argc, char **argv)
 					}
 					}
 					/* encode authpass with base64 */
 					/* encode authpass with base64 */
 					base64_encode_alloc (authpass, strlen(authpass), &abuf);
 					base64_encode_alloc (authpass, strlen(authpass), &abuf);
-					/* FIXME: abuf shouldn't have enough space to strcat a '\r\n' into it. */
-					strcat (abuf, "\r\n");
+					xasprintf(&abuf, "%s\r\n", abuf);
 					my_send(abuf, strlen(abuf));
 					my_send(abuf, strlen(abuf));
 					if (verbose) {
 					if (verbose) {
 						printf (_("sent %s\n"), abuf);
 						printf (_("sent %s\n"), abuf);