func HandleSendInstantMsg(cc *ClientConn, t *Transaction) (res []Transaction, err error) {
if !cc.Authorize(accessSendPrivMsg) {
res = append(res, cc.NewErrReply(t, "You are not allowed to send private messages."))
func HandleSendInstantMsg(cc *ClientConn, t *Transaction) (res []Transaction, err error) {
if !cc.Authorize(accessSendPrivMsg) {
res = append(res, cc.NewErrReply(t, "You are not allowed to send private messages."))
- id, _ := byteToInt(ID.Data)
+ id, err := byteToInt(ID.Data)
+ if err != nil {
+ return res, errors.New("invalid client ID")
+ }
otherClient, ok := cc.Server.Clients[uint16(id)]
if !ok {
return res, errors.New("invalid client ID")
otherClient, ok := cc.Server.Clients[uint16(id)]
if !ok {
return res, errors.New("invalid client ID")
// Check if target user has "Refuse private messages" flag
flagBitmap := big.NewInt(int64(binary.BigEndian.Uint16(otherClient.Flags)))
// Check if target user has "Refuse private messages" flag
flagBitmap := big.NewInt(int64(binary.BigEndian.Uint16(otherClient.Flags)))
NewField(FieldFileTypeString, fw.ffo.FlatFileInformationFork.friendlyType()),
NewField(FieldFileCreatorString, fw.ffo.FlatFileInformationFork.friendlyCreator()),
NewField(FieldFileComment, fw.ffo.FlatFileInformationFork.Comment),
NewField(FieldFileTypeString, fw.ffo.FlatFileInformationFork.friendlyType()),
NewField(FieldFileCreatorString, fw.ffo.FlatFileInformationFork.friendlyCreator()),
NewField(FieldFileComment, fw.ffo.FlatFileInformationFork.Comment),
- hlFile.name = string(fileNewName)
+ hlFile.name, err = txtDecoder.String(string(fileNewName))
+ if err != nil {
+ return res, fmt.Errorf("invalid filepath encoding: %w", err)
+ }
+
err = hlFile.move(fileDir)
if os.IsNotExist(err) {
res = append(res, cc.NewErrReply(t, "Cannot rename file "+string(fileName)+" because it does not exist or cannot be found."))
err = hlFile.move(fileDir)
if os.IsNotExist(err) {
res = append(res, cc.NewErrReply(t, "Cannot rename file "+string(fileName)+" because it does not exist or cannot be found."))
res = append(res, cc.NewErrReply(t, "Cannot delete file "+fileName+" because it does not exist or cannot be found."))
return res, err
}
res = append(res, cc.NewErrReply(t, "Cannot delete file "+fileName+" because it does not exist or cannot be found."))
return res, err
}
if err := cc.Server.FS.Mkdir(newFolderPath, 0777); err != nil {
msg := fmt.Sprintf("Cannot create folder \"%s\" because an error occurred.", folderName)
return []Transaction{cc.NewErrReply(t, msg)}, nil
if err := cc.Server.FS.Mkdir(newFolderPath, 0777); err != nil {
msg := fmt.Sprintf("Cannot create folder \"%s\" because an error occurred.", folderName)
return []Transaction{cc.NewErrReply(t, msg)}, nil
res = append(res, cc.NewReply(t,
NewField(FieldUserName, []byte(account.Name)),
res = append(res, cc.NewReply(t,
NewField(FieldUserName, []byte(account.Name)),
NewField(FieldUserPassword, []byte(account.Password)),
NewField(FieldUserAccess, account.Access[:]),
))
NewField(FieldUserPassword, []byte(account.Password)),
NewField(FieldUserAccess, account.Access[:]),
))
cc.logger.Infow("DeleteUser", "login", login)
if !cc.Authorize(accessDeleteUser) {
cc.logger.Infow("DeleteUser", "login", login)
if !cc.Authorize(accessDeleteUser) {
// check if the login dataFile; if so, we know we are updating an existing user
if acc, ok := cc.Server.Accounts[login]; ok {
// check if the login dataFile; if so, we know we are updating an existing user
if acc, ok := cc.Server.Accounts[login]; ok {
- DecodeUserString(getField(FieldData, &subFields).Data),
- DecodeUserString(getField(FieldUserLogin, &subFields).Data),
+ decodeString(getField(FieldData, &subFields).Data),
+ decodeString(getField(FieldUserLogin, &subFields).Data),
// If the account already dataFile, reply with an error
if _, ok := cc.Server.Accounts[login]; ok {
// If the account already dataFile, reply with an error
if _, ok := cc.Server.Accounts[login]; ok {
binary.BigEndian.PutUint16(cc.Flags, uint16(flagBitmap.Int64()))
}
// Check refuse private chat option
if optBitmap.Bit(refuseChat) == 1 {
binary.BigEndian.PutUint16(cc.Flags, uint16(flagBitmap.Int64()))
}
// Check refuse private chat option
if optBitmap.Bit(refuseChat) == 1 {
}
newsPost := fmt.Sprintf(newsTemplate+"\r", cc.UserName, time.Now().Format(newsDateTemplate), t.GetField(FieldData).Data)
}
newsPost := fmt.Sprintf(newsTemplate+"\r", cc.UserName, time.Now().Format(newsDateTemplate), t.GetField(FieldData).Data)
- newsPost = strings.Replace(newsPost, "\n", "\r", -1)
+ newsPost = strings.ReplaceAll(newsPost, "\n", "\r")
banUntil := time.Now().Add(tempBanDuration)
cc.Server.banList[strings.Split(clientConn.RemoteAddr, ":")[0]] = &banUntil
banUntil := time.Now().Add(tempBanDuration)
cc.Server.banList[strings.Split(clientConn.RemoteAddr, ":")[0]] = &banUntil
case 2:
// send message: "You are permanently banned on this server"
cc.logger.Infow("Disconnect & ban " + string(clientConn.UserName))
case 2:
// send message: "You are permanently banned on this server"
cc.logger.Infow("Disconnect & ban " + string(clientConn.UserName))
optBitmap := big.NewInt(int64(binary.BigEndian.Uint16(options)))
flagBitmap := big.NewInt(int64(binary.BigEndian.Uint16(cc.Flags)))
optBitmap := big.NewInt(int64(binary.BigEndian.Uint16(options)))
flagBitmap := big.NewInt(int64(binary.BigEndian.Uint16(cc.Flags)))
targetClient := cc.Server.Clients[binary.BigEndian.Uint16(targetID)]
flagBitmap := big.NewInt(int64(binary.BigEndian.Uint16(targetClient.Flags)))
targetClient := cc.Server.Clients[binary.BigEndian.Uint16(targetID)]
flagBitmap := big.NewInt(int64(binary.BigEndian.Uint16(targetClient.Flags)))