@@ -214,10 +214,10 @@ func validateTags(tags []Tag) error {
214214 return fmt .Errorf ("tag key cannot be empty" )
215215 }
216216 if len (tag .Key ) > maxTagKeyLen {
217- return fmt .Errorf ("tag key '%s' exceeds maximum length %d" , tag . Key , maxTagKeyLen )
217+ return fmt .Errorf ("tag key exceeds maximum length %d" , maxTagKeyLen )
218218 }
219219 if len (tag .Value ) > maxTagValueLen {
220- return fmt .Errorf ("tag value for key '%s' exceeds maximum length %d" , tag . Key , maxTagValueLen )
220+ return fmt .Errorf ("tag value for key exceeds maximum length %d" , maxTagValueLen )
221221 }
222222
223223 // 检查重复的键
@@ -720,7 +720,11 @@ func (m *Master) handleInfo(w http.ResponseWriter, r *http.Request) {
720720 return
721721 }
722722
723- // 更新alias字段
723+ // 更新主控别名
724+ if len (reqData .Alias ) > maxTagKeyLen {
725+ httpError (w , fmt .Sprintf ("Master alias exceeds maximum length %d" , maxTagKeyLen ), http .StatusBadRequest )
726+ return
727+ }
724728 m .alias = reqData .Alias
725729
726730 writeJSON (w , http .StatusOK , m .getMasterInfo ())
@@ -1092,6 +1096,10 @@ func (m *Master) handlePatchInstance(w http.ResponseWriter, r *http.Request, id
10921096
10931097 // 更新实例别名
10941098 if reqData .Alias != "" && instance .Alias != reqData .Alias {
1099+ if len (reqData .Alias ) > maxTagKeyLen {
1100+ httpError (w , fmt .Sprintf ("Instance alias exceeds maximum length %d" , maxTagKeyLen ), http .StatusBadRequest )
1101+ return
1102+ }
10951103 instance .Alias = reqData .Alias
10961104 m .instances .Store (id , instance )
10971105 go m .saveState ()
0 commit comments