summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-03-10 22:47:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:55:58 -0500
commita9a218f5e64aac1f7fb0608520010ed75d437a4c (patch)
tree33097d5efdeaff6184e7608286b51f9b282a6160
parent95e68fa7f8c109204b3ddaeb530e192c71b40e58 (diff)
downloadsamba-a9a218f5e64aac1f7fb0608520010ed75d437a4c.tar.gz
samba-a9a218f5e64aac1f7fb0608520010ed75d437a4c.tar.bz2
samba-a9a218f5e64aac1f7fb0608520010ed75d437a4c.zip
r5733: Don't crash when the SID column contains NULL (Fixes #2316)
Patch by Justin Ossevoort (This used to be commit a281148168624dcab24e12f1cc7b0f6c7caf0185)
-rw-r--r--source3/passdb/pdb_pgsql.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/source3/passdb/pdb_pgsql.c b/source3/passdb/pdb_pgsql.c
index 0955ea1881..4474bf04e3 100644
--- a/source3/passdb/pdb_pgsql.c
+++ b/source3/passdb/pdb_pgsql.c
@@ -104,10 +104,15 @@ static NTSTATUS row_to_sam_account ( PGresult *r, long row, SAM_ACCOUNT *u )
pdb_set_logon_count ( u, PQgetlong ( r, row, 27 ), PDB_SET ) ;
pdb_set_unknown_6 ( u, PQgetlong ( r, row, 28 ), PDB_SET ) ;
- if ( !PQgetisnull( r, row, 18 ) ) string_to_sid( &sid, PQgetvalue( r, row, 18 ) ) ;
- pdb_set_user_sid ( u, &sid, PDB_SET ) ;
- if ( !PQgetisnull( r, row, 19 ) ) string_to_sid( &sid, PQgetvalue( r, row, 19 ) ) ;
- pdb_set_group_sid( u, &sid, PDB_SET ) ;
+ if ( !PQgetisnull( r, row, 18 ) ) {
+ string_to_sid( &sid, PQgetvalue( r, row, 18 ) ) ;
+ pdb_set_user_sid ( u, &sid, PDB_SET ) ;
+ }
+
+ if ( !PQgetisnull( r, row, 19 ) ) {
+ string_to_sid( &sid, PQgetvalue( r, row, 19 ) ) ;
+ pdb_set_group_sid( u, &sid, PDB_SET ) ;
+ }
if ( pdb_gethexpwd( PQgetvalue( r, row, 20 ), temp ), PDB_SET ) pdb_set_lanman_passwd( u, temp, PDB_SET ) ;
if ( pdb_gethexpwd( PQgetvalue( r, row, 21 ), temp ), PDB_SET ) pdb_set_nt_passwd ( u, temp, PDB_SET ) ;
@@ -146,7 +151,7 @@ static NTSTATUS pgsqlsam_setsampwent(struct pdb_methods *methods, BOOL update, u
}
else
{
- DEBUG( 5, ("pgsqlsam_setsampwent succeeded(%llu results)!\n", PQntuples(data->pwent)) ) ;
+ DEBUG( 5, ("pgsqlsam_setsampwent succeeded(%d results)!\n", PQntuples(data->pwent)) ) ;
retval = NT_STATUS_OK ;
}