kcpuproc.cpp - prevent overflow #2

已關閉
建立於 6 年前 由 Ghost · 2 則留言
Ghost 已留言 6 年前

I've run cppcheck on kcpuload, here is the error:

[kcpuproc.cpp:176]: (error) Width 32 given in format string (no. 1) is larger than destination buffer 'tagbuffer[32]', use %31s to prevent overflowing it.

Instead, I'd like to enlarge the 'tagbuffer' array by 1, but I have no ideas why the guy has set the string to 32 characters.

What do think about?

I've run cppcheck on kcpuload, here is the error: [kcpuproc.cpp:176]: (error) Width 32 given in format string (no. 1) is larger than destination buffer 'tagbuffer[32]', use %31s to prevent overflowing it. Instead, I'd like to enlarge the 'tagbuffer' array by 1, but I have no ideas why the guy has set the string to 32 characters. What do think about?
擁有者

Hi Greg,

yes, increasing the tagbugger to 33 bytes is the correct solution.

Changing the sequence of reading in the fscanf may lead to unexpected results, with bytes after 32 being shifted by one. Extending tagbuffer to allow for the extra null terminator will preserve functionality and avoid mistakes.

Good work!

Hi Greg, yes, increasing the tagbugger to 33 bytes is the correct solution. Changing the sequence of reading in the fscanf may lead to unexpected results, with bytes after 32 being shifted by one. Extending tagbuffer to allow for the extra null terminator will preserve functionality and avoid mistakes. Good work!
SlavekB 新增到 R14.0.6 release 里程碑 6 年前
擁有者

Fixed by PR #4, commit e816bb8048.

Fixed by PR #4, commit e816bb8048.
SlavekB 關閉了這個問題 6 年前
登入 才能加入這對話。
未選擇里程碑
沒有負責人
3 參與者
通知
截止日期

未設定截止日期。

先決條件

未設定先決條件。

參考: TDE/kcpuload#2
載入中…
尚未有任何內容