All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add missing position handling to mount parameters gid/backup_gid/snapshot
@ 2020-11-26  0:28 Simon Arlott
  2020-12-09 19:33 ` Pavel Shilovsky
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Arlott @ 2020-11-26  0:28 UTC (permalink / raw)
  To: linux-cifs

The code tries to optimise for the last parameter not needing to update
the position which means that every time a new one is added to the end
by copying and pasting, the string position is not updated.

That makes it impossible to use backup_uid=/backup_gid=/snapshot= after
gid= or snapshot= after backup_gid= because part of the string is
overwritten and contains invalid keys like "gbackup_uid".

Prepare for the next parameter to be added on the end by updating the
position for snapshot= even though it will be unused.
---
 mount.cifs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mount.cifs.c b/mount.cifs.c
index 4feb397..a169bc6 100644
--- a/mount.cifs.c
+++ b/mount.cifs.c
@@ -1229,6 +1229,7 @@ nocopy:
 			out_len++;
 		}
 		snprintf(out + out_len, word_len + 5, "gid=%s", txtbuf);
+		out_len = strlen(out);
 	}
 	if (got_bkupuid) {
 		word_len = snprintf(txtbuf, sizeof(txtbuf), "%u", bkupuid);
@@ -1260,6 +1261,7 @@ nocopy:
 			out_len++;
 		}
 		snprintf(out + out_len, word_len + 11, "backupgid=%s", txtbuf);
+		out_len = strlen(out);
 	}
 	if (got_snapshot) {
 		word_len = snprintf(txtbuf, sizeof(txtbuf), "%llu", snapshot);
@@ -1275,6 +1277,7 @@ nocopy:
 			out_len++;
 		}
 		snprintf(out + out_len, word_len + 11, "snapshot=%s", txtbuf);
+		out_len = strlen(out);
 	}
 
 	return 0;
-- 
2.17.1

-- 
Simon Arlott

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Add missing position handling to mount parameters gid/backup_gid/snapshot
  2020-11-26  0:28 [PATCH] Add missing position handling to mount parameters gid/backup_gid/snapshot Simon Arlott
@ 2020-12-09 19:33 ` Pavel Shilovsky
  0 siblings, 0 replies; 2+ messages in thread
From: Pavel Shilovsky @ 2020-12-09 19:33 UTC (permalink / raw)
  To: Simon Arlott; +Cc: linux-cifs

Merged. Thanks!
--
Best regards,
Pavel Shilovsky

ср, 25 нояб. 2020 г. в 16:38, Simon Arlott <simon@octiron.net>:
>
> The code tries to optimise for the last parameter not needing to update
> the position which means that every time a new one is added to the end
> by copying and pasting, the string position is not updated.
>
> That makes it impossible to use backup_uid=/backup_gid=/snapshot= after
> gid= or snapshot= after backup_gid= because part of the string is
> overwritten and contains invalid keys like "gbackup_uid".
>
> Prepare for the next parameter to be added on the end by updating the
> position for snapshot= even though it will be unused.
> ---
>  mount.cifs.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/mount.cifs.c b/mount.cifs.c
> index 4feb397..a169bc6 100644
> --- a/mount.cifs.c
> +++ b/mount.cifs.c
> @@ -1229,6 +1229,7 @@ nocopy:
>                         out_len++;
>                 }
>                 snprintf(out + out_len, word_len + 5, "gid=%s", txtbuf);
> +               out_len = strlen(out);
>         }
>         if (got_bkupuid) {
>                 word_len = snprintf(txtbuf, sizeof(txtbuf), "%u", bkupuid);
> @@ -1260,6 +1261,7 @@ nocopy:
>                         out_len++;
>                 }
>                 snprintf(out + out_len, word_len + 11, "backupgid=%s", txtbuf);
> +               out_len = strlen(out);
>         }
>         if (got_snapshot) {
>                 word_len = snprintf(txtbuf, sizeof(txtbuf), "%llu", snapshot);
> @@ -1275,6 +1277,7 @@ nocopy:
>                         out_len++;
>                 }
>                 snprintf(out + out_len, word_len + 11, "snapshot=%s", txtbuf);
> +               out_len = strlen(out);
>         }
>
>         return 0;
> --
> 2.17.1
>
> --
> Simon Arlott

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-09 19:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-26  0:28 [PATCH] Add missing position handling to mount parameters gid/backup_gid/snapshot Simon Arlott
2020-12-09 19:33 ` Pavel Shilovsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.