Bug 2703 - it's necessary to check disp_fields[0] for NULL in utils/net_ads.c
Summary: it's necessary to check disp_fields[0] for NULL in utils/net_ads.c
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: net utility (show other bugs)
Version: 3.0.14a
Hardware: All Linux
: P3 major
Target Milestone: none
Assignee: Jim McDonough
QA Contact: Samba QA Contact
Depends on:
Reported: 2005-05-12 09:56 UTC by John Antonishek
Modified: 2005-08-24 10:26 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description John Antonishek 2005-05-12 09:56:05 UTC
"net user" causes segmentation fault in my environment after printing several
hundred names.  I tracked it down to the call to strchr_m utils/net_ads.c:253.
I fixed it by doing:

if (disp_fields[0]) {
                if (!strchr_m(disp_fields[0], '$')) {
                        if (disp_fields[1])
                                d_printf("%-21.21s %s\n",
                                       disp_fields[0], disp_fields[1]);
                                d_printf("%s\n", disp_fields[0]);

I figured it out from the gdb trace, notice the src=0x0 in strchr_m:

Program received signal SIGSEGV, Segmentation fault.
0x00bde603 in strchr () from /lib/tls/libc.so.6
(gdb) where
#0  0x00bde603 in strchr () from /lib/tls/libc.so.6
#1  0x0814f4c0 in strchr_m (src=0x0, c=36 '$') at lib/util_str.c:1214
#2  0x08071478 in usergrp_display (field=0x0, values=0x0, data_area=0xbffff408)
at utils/net_ads.c:253
#3  0x08194dbe in ads_process_results (ads=0x827e988, res=0x8280c48,
fn=0x8071453 <usergrp_display>, data_area=0xbffff408)
    at libads/ldap.c:1712
#4  0x08192266 in ads_do_search_all_fn (ads=0x827e988, bind_path=0x8280ae8
"dc=CAMPUS,dc=NIST,dc=GOV", scope=2,
    expr=0x81a9e56 "(objectclass=user)", attrs=0xbffff428, fn=0x8071453
<usergrp_display>, data_area=0xbffff408)
    at libads/ldap.c:641
#5  0x08071ce1 in net_ads_user (argc=0, argv=0x820c1a8) at utils/net_ads.c:464
#6  0x0806ff81 in net_user (argc=0, argv=0x820c1a8) at utils/net.c:383
#7  0x0806f6b8 in net_run_function (argc=1, argv=0x820c1a4, table=0x81f2d40,
usage_fn=0x80751c7 <net_help>)
    at utils/net.c:128
#8  0x08070d87 in main (argc=2, argv=0xbffff8d4) at utils/net.c:895

I hope this helps!

-John Antonishek
Comment 1 Jeremy Allison 2005-05-16 15:55:03 UTC
Applied, thanks.
Comment 2 Gerald (Jerry) Carter (dead mail address) 2005-08-24 10:26:00 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.