[Bug 4496] passwd applet ruins UID field in /etc/passwd

bugzilla at busybox.net bugzilla at busybox.net
Tue Nov 22 00:55:10 UTC 2011


https://bugs.busybox.net/show_bug.cgi?id=4496

--- Comment #8 from Denys Vlasenko <vda.linux at googlemail.com> 2011-11-22 00:55:09 UTC ---
(In reply to comment #4)
> Created attachment 3758 [details]
> libbb/update_passwd.s (CONFIG_DEBUG=n)

Here strstr(filename, "shadow") is saved to [sp, #20]

        ldr     r1, .L31        @,
        mov     r4, r0  @ filename, filename
        str     r2, [sp, #32]   @ new_passwd, %sfp
        bl      strstr  @
        str     r0, [sp, #20]   @, %sfp

and here it is retrieved to check for != NULL. If non-NULL, then date is
inserted.

        ldr     r3, [sp, #20]   @, %sfp
        cmp     r3, #0  @,
        beq     .L18    @,
        ldrb    r1, [r0, #0]    @ zero_extendqisi2      @ tmp218,* cp
        cmp     r1, #58 @ tmp218,
        bne     .L18    @,
        add     r0, r0, #1      @, cp,
        bl      strchrnul       @
        mov     r3, r0  @ cp,
        ldr     r0, [sp, #36]   @, %sfp
        str     r3, [sp, #12]   @,
        bl      time    @
        ldr     r1, .L31+44     @,
        bl      __aeabi_uidiv   @
        ldr     r3, [sp, #12]   @,
        ldr     r1, .L31+48     @,
        stmia   sp, {r0, r3}    @ phole stm
        mov     r0, r8  @, new_fp
        b       .L29    @
.L18:

Both these code parts look ok.

Your debug printouts in comment #1 point towards a bug in strstr
implementation.
You might want to step into strstr call under gdb when filename = "/etc/passwd"
and find out how the hell does it manage to return non-NULL in this case.

Which libc do you use?

Can you disassemble busybox (objdump -dr busybox) and post here the fragment
which shows strstr function's assembly code?

-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the busybox-cvs mailing list