[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: The --password and clumsy users issue

From: Gabriela Gibson <gabriela.gibson_at_gmail.com>
Date: Fri, 4 Jul 2014 01:14:10 +0100

I also looked at the C90 standard because I thought maybe they defined argv
as immutable (since it should not complain about being const with this type
of main declaration I think) and this is what is says:

"The parameters argc and argv and the strings pointed to by the argv array
shall
 be modifiable by the program, and retain their last-stored values between
program
 startup and program termination."

This seems a bit ambiguous --- so it's changeable, but between start up and
termination they retain their value?

So, that is maybe why the kernel's info isn't changing but the args can be
modified?

G

On Fri, Jul 4, 2014 at 12:50 AM, Gabriela Gibson <gabriela.gibson_at_gmail.com>
wrote:

> Oh, I was playing about with this earlier, but didn't get all that far:
>
> I go this far in svn.c (has breakpoint marker in it)
>
> [[[
> int
>
> main(int argc, char **argv)
>
> {
>
> apr_pool_t *pool;
>
> int exit_code = EXIT_SUCCESS;
>
> svn_error_t *err;
>
> const char **argv_org;
>
>
>
> /* Initialize the app. */
>
> if (svn_cmdline_init("svn", stderr) != EXIT_SUCCESS)
>
> return EXIT_FAILURE;
>
>
>
> /* Create our top-level pool. Use a separate mutexless allocator,
>
> * given this application is single threaded.
>
> */
>
> pool = apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
>
>
>
> {
> int i;
>
>
>
> argv_org = apr_palloc(pool, sizeof(argv));
>
>
>
> B for(i = 0; i < argc; i++)
>
> {
>
> argv_org[i] = apr_pstrdup(pool, argv[i]);
>
> if (i > 2 && !strcmp(argv[i-1],"--password"))
>
> {
>
> argv[i-1] = "#####\0";
>
> }
>
> if (i > 2 && !strcmp(argv[i-1],"--username"))
>
> {
>
> argv[i-1] = "#####\0";
>
> }
>
>
>
> }
>
> }
> ]]]
>
>
> it compiles and runs and in gdb the vars do change, but the compiler isn't
> happy:
> subversion/svn/svn.c: In function 'main':
>
> subversion/svn/svn.c:3048:23: warning: assignment discards 'const'
> qualifier from pointer target type [enable\
> d by default]
>
> argv[i-1] = "#####\0";
>
> ^
>
> subversion/svn/svn.c:3052:23: warning: assignment discards 'const'
> qualifier from pointer target type [enable\
> d by default]
>
> argv[i-1] = "#####\0";
>
> At breakpoint B, gdb gives me:
>
> (gdb) p argv
>
> $1 = (char **) 0x7fffffffe468
>
> (gdb) p argv[1]
>
> $2 = 0x7fffffffe81e "svn"
>
> (gdb) p argv[2]
>
> $3 = 0x7fffffffe822 "help"
>
> (gdb) p argv[3]
>
> $4 = 0x4438b3 "#####"
>
> (gdb)
>
> So it def. does change it.
>
>
> On Fri, Jul 4, 2014 at 12:40 AM, Ben Reser <ben_at_reser.org> wrote:
>
>> On 7/3/14 4:23 PM, Gabriela Gibson wrote:
>> > Could that be because of the libtool svn-lt script that sits in the
>> middle?
>> > Because in gdb it does change, but not in ps.
>>
>> No because I wasn't even doing anything with Subversion yet let alone
>> libtool.
>> It was just a very basic C program with nothing more than a main. It's
>> probably because the argv array belongs to the process itself and then it
>> points to memory that the kernel owns (or at least watches). I'm not
>> sure on
>> all the details of how the kernel starts the binary and passes in the
>> arguments.
>>
>> I've attached the example I was working with that didn't make it to this
>> list
>> already.
>>
>>
>
>
> --
> Visit my Coding Diary: http://gabriela-gibson.blogspot.com/
>

-- 
Visit my Coding Diary: http://gabriela-gibson.blogspot.com/
Received on 2014-07-04 02:14:40 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.