From ba19046acbc1cd6f0a39c491b9add2dffbaf20e1 Mon Sep 17 00:00:00 2001 From: ykpcx <52552971+xcpky@users.noreply.github.com> Date: Mon, 20 Jan 2025 00:08:23 +0800 Subject: [PATCH] fix(config): correct the truncation of process name(comm name) (#738) --- component/routing/function_parser.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/component/routing/function_parser.go b/component/routing/function_parser.go index d27c78223d..7df33c9254 100644 --- a/component/routing/function_parser.go +++ b/component/routing/function_parser.go @@ -112,8 +112,8 @@ func ProcessNameParserFactory(callback func(f *config_parser.Function, procNames return func(log *logrus.Logger, f *config_parser.Function, key string, paramValueGroup []string, overrideOutbound *Outbound) (err error) { var procNames [][consts.TaskCommLen]byte for _, v := range paramValueGroup { - if len([]byte(v)) > consts.TaskCommLen { - log.Infof(`pname routing: trim "%v" to "%v" because it is too long.`, v, string([]byte(v)[:consts.TaskCommLen])) + if len([]byte(v)) > consts.TaskCommLen - 1 { + log.Infof(`pname routing: trim "%v" to "%v" because it is too long.`, v, string([]byte(v)[:consts.TaskCommLen-1])) } procNames = append(procNames, toProcessName(v)) } @@ -138,7 +138,7 @@ func parsePrefixes(values []string) (cidrs []netip.Prefix, err error) { func toProcessName(processName string) (procName [consts.TaskCommLen]byte) { n := []byte(processName) - copy(procName[:], n) + copy(procName[:consts.TaskCommLen-1], n) return procName }