diff --git a/vfs/ChangeLog b/vfs/ChangeLog index e731b1354..89a61fae8 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,3 +1,9 @@ +2004-09-01 Pavel S. Shirshov + + * fish.c (fish_get_reply): Use g_strlcpy instead + sequence strncpy(), name[len] = '\0' + * vfs.c (mc_get_current_wd): Likewise. + 2004-08-31 Andrew V. Samoilov * utilvfs.c (vfs_parse_ls_lga): Use atoll()/atof() instead of atol() diff --git a/vfs/fish.c b/vfs/fish.c index e5fbb0acb..8cac38cca 100644 --- a/vfs/fish.c +++ b/vfs/fish.c @@ -104,12 +104,11 @@ static int fish_get_reply (struct vfs_class *me, int sock, char *string_buf, int *string_buf = 0; return 4; } + if (strncmp(answer, "### ", 4)) { was_garbage = 1; - if (string_buf) { - strncpy(string_buf, answer, string_len - 1); - *(string_buf + string_len - 1) = 0; - } + if (string_buf) + g_strlcpy(string_buf, answer, string_len); } else return fish_decode_reply(answer+4, was_garbage); } } diff --git a/vfs/vfs.c b/vfs/vfs.c index 7ecf41fbc..7a8f115fd 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -601,8 +601,7 @@ mc_get_current_wd (char *buffer, int size) { const char *cwd = _vfs_get_cwd (); - g_strlcpy (buffer, cwd, size - 1); - buffer[size - 1] = 0; + g_strlcpy (buffer, cwd, size); return buffer; }