mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-18 09:19:24 +03:00
Ticket #1935: Incorrect lock files check when hostname contains wide characters.
Bug: in lock_extract_info() number of unicode characters is used as number of bytes in string. Now strlen() is used instead of str_term_width() to calculate string length. String length is calculated only one time. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
173d2d4b90
commit
70a41e4fed
@ -117,12 +117,14 @@ lock_build_symlink_name (const char *fname)
|
|||||||
static struct lock_s *
|
static struct lock_s *
|
||||||
lock_extract_info (const char *str)
|
lock_extract_info (const char *str)
|
||||||
{
|
{
|
||||||
int i;
|
size_t i, len;
|
||||||
const char *p, *s;
|
const char *p, *s;
|
||||||
static char pid[PID_BUF_SIZE], who[BUF_SIZE];
|
static char pid[PID_BUF_SIZE], who[BUF_SIZE];
|
||||||
static struct lock_s lock;
|
static struct lock_s lock;
|
||||||
|
|
||||||
for (p = str + str_term_width1 (str) - 1; p >= str; p--)
|
len = strlen (str);
|
||||||
|
|
||||||
|
for (p = str + len - 1; p >= str; p--)
|
||||||
if (*p == '.')
|
if (*p == '.')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -134,8 +136,7 @@ lock_extract_info (const char *str)
|
|||||||
|
|
||||||
/* Treat text between '.' and ':' or '\0' as pid */
|
/* Treat text between '.' and ':' or '\0' as pid */
|
||||||
i = 0;
|
i = 0;
|
||||||
for (p = p + 1;
|
for (p = p + 1; (p < str + len) && (*p != ':') && (i < PID_BUF_SIZE); p++)
|
||||||
p < str + str_term_width1 (str) && *p != ':' && i < PID_BUF_SIZE; p++)
|
|
||||||
pid[i++] = *p;
|
pid[i++] = *p;
|
||||||
pid[i] = '\0';
|
pid[i] = '\0';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user