Skip to content

Commit ba19046

Browse files
authoredJan 19, 2025··
fix(config): correct the truncation of process name(comm name) (#738)
1 parent fb88e07 commit ba19046

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎component/routing/function_parser.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ func ProcessNameParserFactory(callback func(f *config_parser.Function, procNames
112112
return func(log *logrus.Logger, f *config_parser.Function, key string, paramValueGroup []string, overrideOutbound *Outbound) (err error) {
113113
var procNames [][consts.TaskCommLen]byte
114114
for _, v := range paramValueGroup {
115-
if len([]byte(v)) > consts.TaskCommLen {
116-
log.Infof(`pname routing: trim "%v" to "%v" because it is too long.`, v, string([]byte(v)[:consts.TaskCommLen]))
115+
if len([]byte(v)) > consts.TaskCommLen - 1 {
116+
log.Infof(`pname routing: trim "%v" to "%v" because it is too long.`, v, string([]byte(v)[:consts.TaskCommLen-1]))
117117
}
118118
procNames = append(procNames, toProcessName(v))
119119
}
@@ -138,7 +138,7 @@ func parsePrefixes(values []string) (cidrs []netip.Prefix, err error) {
138138

139139
func toProcessName(processName string) (procName [consts.TaskCommLen]byte) {
140140
n := []byte(processName)
141-
copy(procName[:], n)
141+
copy(procName[:consts.TaskCommLen-1], n)
142142
return procName
143143
}
144144

0 commit comments

Comments
 (0)
Please sign in to comment.