the string is consumed as well. Right now a string of 'dir1/' and a
pattern of 'dir/' will result in an infinite loop because matchsub()
would return success but then would not move forward.
Report and diff from Kyle Evans (kevans FreeBSD.org)
OK tb@
-/* $OpenBSD: rmatch.c,v 1.3 2022/12/26 19:16:02 jmc Exp $ */
+/* $OpenBSD: rmatch.c,v 1.4 2024/02/20 10:36:23 claudio Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
/* eat possible escape char before '/' */
if (pattern[0] == '\\' && pattern[1] == '/')
pattern++;
- if (pattern[0] == '/')
+ if (pattern[0] == '/') {
+ /* hit the barrier but we still have characters left */
+ if (string < end)
+ return 1;
break;
+ }
/* check if there are still characters available to compare */
if (string >= end)