[pulseaudio-discuss] [PATCH] pactl: fix getopt indexing for set-*-volume

David Henningsson david.henningsson at canonical.com
Thu Jan 8 04:25:50 PST 2015


Pushed now. Good catch!

On 2015-01-08 01:01, Felipe Sateler wrote:
> When pactl is invoked with any options or the -- specifier, optind will
> be > 1. Therefore using a static 3 value is wrong. Use optind+2 as both
> offset and count difference.
>
> Bug-Debian: http://bugs.debian.org/774810
> ---
>   src/utils/pactl.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/utils/pactl.c b/src/utils/pactl.c
> index f6555b9..35dd04e 100644
> --- a/src/utils/pactl.c
> +++ b/src/utils/pactl.c
> @@ -1897,7 +1897,7 @@ int main(int argc, char *argv[]) {
>
>               sink_name = pa_xstrdup(argv[optind+1]);
>
> -            if (parse_volumes(argv+optind+2, argc-3) < 0)
> +            if (parse_volumes(argv+optind+2, argc-(optind+2)) < 0)
>                   goto quit;
>
>           } else if (pa_streq(argv[optind], "set-source-volume")) {
> @@ -1910,7 +1910,7 @@ int main(int argc, char *argv[]) {
>
>               source_name = pa_xstrdup(argv[optind+1]);
>
> -            if (parse_volumes(argv+optind+2, argc-3) < 0)
> +            if (parse_volumes(argv+optind+2, argc-(optind+2)) < 0)
>                   goto quit;
>
>           } else if (pa_streq(argv[optind], "set-sink-input-volume")) {
> @@ -1926,7 +1926,7 @@ int main(int argc, char *argv[]) {
>                   goto quit;
>               }
>
> -            if (parse_volumes(argv+optind+2, argc-3) < 0)
> +            if (parse_volumes(argv+optind+2, argc-(optind+2)) < 0)
>                   goto quit;
>
>           } else if (pa_streq(argv[optind], "set-source-output-volume")) {
> @@ -1942,7 +1942,7 @@ int main(int argc, char *argv[]) {
>                   goto quit;
>               }
>
> -            if (parse_volumes(argv+optind+2, argc-3) < 0)
> +            if (parse_volumes(argv+optind+2, argc-(optind+2)) < 0)
>                   goto quit;
>
>           } else if (pa_streq(argv[optind], "set-sink-mute")) {
>

-- 
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic


More information about the pulseaudio-discuss mailing list