card lock not released in error path
維護者通常 2 天內回覆
評估
研究方向
從 src/libopensc/card.c 中的 sc_unlock 開始,這是 issue 中指出的函式和錯誤條件。追蹤 mutex 的取得方式,以及 invalid lock_count 路徑如何返回;issue 沒有指定測試,作者也找不到重現方法。完成標準是該錯誤路徑在返回前釋放 mutex,並透過迴歸檢查確認之後呼叫 sc_lock 或 sc_unlock 不會阻塞。
由索引模型根據 Issue 內容生成。
描述
Describe the bug
In card.c function sc_unlock L514 the mutex card->mutex is locked. But in the case card->lock_count < 1 the lock is not released. Thus the next call to sc_lock / sc_unlock will block forever.
r = sc_mutex_lock(card->ctx, card->mutex);
if (r != SC_SUCCESS)
LOG_FUNC_RETURN(card->ctx, r);
if (card->lock_count < 1) {
// lock not released and function returns
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
}
Of course, in the case all calls are correctly balanced this bug is not triggered.
Steps to reproduce
Its only obvious, but I haven't found a way to trigger it.
Expected behavior
The lock should be released when the funtions returns in case card->lock_count < 1
Actual behavior
lock still held
OpenSC version
current git
Operating system
linux
Smart card model or security token
No response
Application used with smart card
No response
Logs and debug output
Checklist
- I am using a supported OpenSC version
- I have searched existing issues to avoid duplicates
- 主要語言
- C
- 星號
- 3.1k
- 分支
- 858
- 平均合併
- 4 天 4 小時
- 30 天內合併 PR
- 16
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
OpenSC/OpenSC 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 2 天內回覆
-
Commit from 08.10.26 breaks caching可能已有人在做 @mvogt1 於 6 天前認領。 未關閉bug
難度 1/5 1 小時以內 新手友好度 85/100
維護者通常 2 天內回覆
-
bug
難度 4/5 3-5 天 新手友好度 18/100
維護者通常 2 天內回覆
-
enhancement
難度 3/5 1-2 天 新手友好度 66/100
維護者通常 2 天內回覆
-
iasecc: iasecc_sdo_parse() wipes the SDO on every successful field parse, breaking PIN policy / C_Login (CKR_GENERAL_ERROR)可能已有人在做 @igeorgiev42 於 15 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 25/100
維護者通常 2 天內回覆
相似的 Issue
-
native-cpu: -Wreturn-type in skainet_row_threads.c:150 (worker fn has no return)可能已有人在做 @Doomguy-BFG9000 今天認領。 未關閉good first issue size:xs skill:native
難度 1/5 1 小時以內 新手友好度 78/100
SKaiNET-developers/SKaiNET#1358 · 1 則留言 ·
維護者通常 1 天內回覆
-
I/O internal correctness medium priority rt_lib
難度 2/5 1-3 小時 新手友好度 79/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 64/100
libsdl-org/SDL#16539 ·
維護者通常 1 天內回覆
-
git-workflow task-4
難度 2/5 1-3 小時 新手友好度 66/100
-
bug
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆