Hacker News | 📄 原文链接 | 2026-07-16 收录

SQLite 字符串中的空字符处理

来源:sqlite.org — 2026-07-16

📋 概述

SQLite 对字符串中的 NUL 字符采取开放态度——不像大多数数据库那样在遇到 NUL 时截断字符串。SQLite 使用长度前缀而非 NUL 终止符来存储字符串,因此 NUL 字符可以合法地出现在字符串中间。但这也带来了隐患:许多上层语言和 API(如 C 的 printf、Java 的 JNI)以 NUL 作为字符串结束标志,SQLite 的宽容可能导致数据在传递过程中被意外截断或产生 安全漏洞

🔑 核心要点

💡 金句

SQLite does not care about NUL characters. It will happily store them in the middle of a string. Your application, however, may not be so accommodating.
← 返回 Hacker News 首页