error reporting in smbpasswd

Tavis Barr tavis at mahler.econ.columbia.edu
Tue Oct 3 04:17:55 GMT 2000


This is really just a suggestion for whoever is maintaining smbpasswd (if 
such a designated person exists), everyone else can probably ignore.

Also, I've only checked smbpasswd.c through 2.0.7; if it has changed then 
you can also ignore this.

I recently was having problems with smbpasswd not working and reporting 
"out of memory" upon failing.  The problem in fact turned out to be the 
permissions on /dev/tty, which in turn caused the C library function 
getpass() to fail, which in turn caused smbpasswd to fail.

The problem is that there is sort of a generic failure point in the 
xstrdup() routine (in smbpasswd.c), which checks to make sure that the 
pointer it creates is non empty, and fails if it is empty, guessing 
that it is out of memory.  However, there are about five places where 
this routine is called, each of them could potentially pass a null 
argument to xstrdup() because something had already gone wrong, causing 
strdup() to report an out of memory error when the problem was something 
completely different.  

A few changes might be helpful:

*two error checks with an exit in getpass(), once after each password 
retrieval function, specifying which function call failed to return 
correctly

* In the two places where xstrdup() is called under the condition 
!user_name, it might be better to check for the existence of pwd->pwname 
and not just pwd.  

I'm sorry I don't have diffs but I don't know which CVS tree would be 
changed anyway.  If you feel these are stupid suggestions feel free to 
ignore them.  I'm only making them because I had to spend several hours 
going through the source to figure out the cause of an error that might 
have only taken a few minutes to diagnose with a more accurate error 
message.  


Cheers,
Tavis



--------------------------------------------------------

Tavis Barr                           ,-~~-.___.        
Senior Systems Coordinator          / |  '     \             
Institute for Social and Economic  (  )        0               
   Theory and Research              \_/-, ,----'            
509D Int'l Affairs Bldg                ====           //                    
Columbia University                   /  \-'~;    /~~~(O)
212-854-9076                         /  __/~|   /       |    
tavis at mahler.econ.columbia.edu     =(  _____| (_________|

---------------------------------------------------------



















More information about the samba-technical mailing list