From 3ed11f53e53da55c44302569d74fe14d60185399 Mon Sep 17 00:00:00 2001 From: CismonX Date: Sun, 26 Jan 2025 19:35:03 +0800 Subject: [PATCH] backend: fix xattr bookmark title check Do not check if the bookmark title is a valid filename, as we said in the user manual. However, we should ensure that the string does not contain NUL characters, since we assume that a valid bookmark storage should not contain bookmarks with such names. --- doc/bookmarkfs.texi | 8 ++++---- src/backend_chromium.c | 2 +- src/backend_firefox.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/bookmarkfs.texi b/doc/bookmarkfs.texi index b4932f1..0ad9030 100644 --- a/doc/bookmarkfs.texi +++ b/doc/bookmarkfs.texi @@ -1210,8 +1210,8 @@ Extended attributes: The bookmark title. Only available with @option{filename=guid}. -This value is allowed be set to any string that is valid UTF-8, -and does not have to be valid as a filename. +This value is allowed be set to any string that does not contain a +NUL character, and does not have to be valid as a filename. @item guid The bookmark GUID. @@ -1343,8 +1343,8 @@ Extended attributes: The bookmark title. Only available with @option{filename=guid}. -This value is allowed be set to any string that is valid UTF-8, -and does not have to be valid as a filename. +This value is allowed be set to any UTF-8 string that does not contain a +NUL character, and does not have to be valid as a filename. @item guid The bookmark GUID. diff --git a/src/backend_chromium.c b/src/backend_chromium.c index b79ca80..50c86cf 100644 --- a/src/backend_chromium.c +++ b/src/backend_chromium.c @@ -2663,7 +2663,7 @@ bookmark_set ( break; case ATTR_KEY_TITLE: - if (0 != validate_filename(val, val_len, NULL)) { + if (NULL != memchr(val, '\0', val_len)) { return -EINVAL; } nocheck = false; diff --git a/src/backend_firefox.c b/src/backend_firefox.c index e0ec5de..2e2315d 100644 --- a/src/backend_firefox.c +++ b/src/backend_firefox.c @@ -3650,7 +3650,7 @@ bookmark_set ( break; case ATTR_KEY_TITLE: - if (0 != validate_filename(val, val_len, NULL)) { + if (NULL != memchr(val, '\0', val_len)) { return -EINVAL; } bm_cols.title = val;