Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load data will panic if the content is break at escape character #31589

Closed
xiongjiwei opened this issue Jan 12, 2022 · 1 comment · Fixed by #30868
Closed

load data will panic if the content is break at escape character #31589

xiongjiwei opened this issue Jan 12, 2022 · 1 comment · Fixed by #30868
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. fixes-5.1.4 severity/major sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@xiongjiwei
Copy link
Contributor

xiongjiwei commented Jan 12, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

tidb/executor/load_data.go

Lines 550 to 568 in 79171be

nextDataIdx := curStartIdx + endIdx + terminatedLen
if len(prevData) == 0 {
return curData[curStartIdx : curStartIdx+endIdx], curData[nextDataIdx:], true
}
// terminated symbol in the curData
prevData = append(prevData, curData[:nextDataIdx]...)
if ignore {
endIdx = strings.Index(string(hack.String(prevData[startingLen:])), e.LinesInfo.Terminated)
} else {
endIdx = e.IndexOfTerminator(prevData[startingLen:], inquotor)
}
if endIdx >= prevLen {
return prevData[startingLen : startingLen+endIdx], curData[nextDataIdx:], true
}
// terminated symbol in the middle of prevData and curData
lineLen := startingLen + endIdx + terminatedLen
return prevData[startingLen : startingLen+endIdx], curData[lineLen-prevLen:], true

if data is broken at escape character and then followed by a \n, then it will get the wrong index of the new line, it will cause panic

@xiongjiwei xiongjiwei added the type/bug The issue is confirmed as a bug. label Jan 12, 2022
@xiongjiwei xiongjiwei added the sig/transaction SIG:Transaction label Jan 12, 2022
@jebter jebter added the affects-5.4 This bug affects 5.4.x versions. label Jan 12, 2022
@xiongjiwei xiongjiwei added affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. labels Jan 12, 2022
@yudongusa yudongusa assigned yudongusa and cfzjywxk and unassigned yudongusa Jan 12, 2022
@github-actions
Copy link

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. fixes-5.1.4 severity/major sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants