From 5693341f0d268b8bf869543aa1547fcfad60e676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Wed, 22 Jun 2016 11:58:20 +0200 Subject: [PATCH] Fixed ntfs_delete() failure caused by string conversion error It was possible for ntfs_attr_name_get() to set errno due to a wide character string that could not be converted to a multibyte string. This caused ntfs_delete() to fail. Fix by checking for a nonzero return value specifically from ntfs_attr_lookup(), rather than assuming that nothing else sets errno. Signed-off-by: Eric Biggers --- libntfs-3g/dir.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libntfs-3g/dir.c b/libntfs-3g/dir.c index ce69eaf3..bd049d2d 100644 --- a/libntfs-3g/dir.c +++ b/libntfs-3g/dir.c @@ -1904,12 +1904,11 @@ int ntfs_delete(ntfs_volume *vol, const char *pathname, if (!actx) goto err_out; search: - while (!ntfs_attr_lookup(AT_FILE_NAME, AT_UNNAMED, 0, CASE_SENSITIVE, - 0, NULL, 0, actx)) { + while (!(err = ntfs_attr_lookup(AT_FILE_NAME, AT_UNNAMED, 0, + CASE_SENSITIVE, 0, NULL, 0, actx))) { char *s; IGNORE_CASE_BOOL case_sensitive = IGNORE_CASE; - errno = 0; fn = (FILE_NAME_ATTR*)((u8*)actx->attr + le16_to_cpu(actx->attr->value_offset)); s = ntfs_attr_name_get(fn->file_name, fn->file_name_length); @@ -1958,7 +1957,7 @@ search: break; } } - if (errno) { + if (err) { /* * If case sensitive search failed, then try once again * ignoring case.