Skip to content

Commit

Permalink
Handle a lack of login/password information without segfaulting.
Browse files Browse the repository at this point in the history
If datacopy is called incorrectly with, e.g., /dev/null on stdin, it won't
get any database login/password information.  We should print an error
message and exit instead of throwing a segfault trying to copy a null
pointer.

Rather than exiting immediately, though, just try to connect to the
databases without a username/password, because hey, you never know.

Bug-Debian: http://bugs.debian.org/715785
  • Loading branch information
vorlonofportland authored and freddy77 committed Oct 18, 2013
1 parent 2a493c3 commit e749d25
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/apps/datacopy.c
Expand Up @@ -455,8 +455,10 @@ login_to_databases(BCPPARAMDATA * pdata, DBPROCESS ** dbsrc, DBPROCESS ** dbdest

slogin = dblogin();

DBSETLUSER(slogin, pdata->suser);
DBSETLPWD(slogin, pdata->spass);
if (pdata->suser)
DBSETLUSER(slogin, pdata->suser);
if (pdata->spass)
DBSETLPWD(slogin, pdata->spass);
DBSETLAPP(slogin, "Migrate Data");

/* if packet size specified, set in login record */
Expand All @@ -481,8 +483,10 @@ login_to_databases(BCPPARAMDATA * pdata, DBPROCESS ** dbsrc, DBPROCESS ** dbdest

dlogin = dblogin();

DBSETLUSER(dlogin, pdata->duser);
DBSETLPWD(dlogin, pdata->dpass);
if (pdata->duser)
DBSETLUSER(dlogin, pdata->duser);
if (pdata->dpass)
DBSETLPWD(dlogin, pdata->dpass);
DBSETLAPP(dlogin, "Migrate Data");

/* Enable bulk copy for this connection. */
Expand Down

0 comments on commit e749d25

Please sign in to comment.