Skip Menu |
 

Subject: krb5-1.6: segfault on password change
Getting segfault when trying to change the password.

The reason is a typo in a memset call and an use of an uninizialied
variable in lib/krb5/os/sendto_kdc.c

A patch is attached.
--- src/lib/krb5/os/sendto_kdc.c
+++ src/lib/krb5/os/sendto_kdc.c 2007/01/17 14:17:10
@@ -1100,7 +1100,7 @@
struct sockaddr *remoteaddr, socklen_t *remoteaddrlen,
int *addr_used)
{
- int i, pass;
+ int i = 0, pass;
int delay_this_pass = 2;
krb5_error_code retval;
struct conn_state *conns;
@@ -1135,7 +1135,7 @@
return ENOMEM;
}

- memset(conns, 0, n_conns * sizeof(callback_data[i]));
+ memset(callback_data, 0, n_conns * sizeof(callback_data[i]));
}

for (i = 0; i < n_conns; i++) {
From: jaltman@mit.edu
Subject: SVN Commit
sendto_kdc.c: use of a variable index into a dynamically
allocated array to determine the sizeof() an object makes
it unclear what type of object is involved. It also requires
a runtime check instead of a compile time replacement.
Not to mention that it could lead to the evaluation of an
uninitialized variable as was done in this case. Replace
sizeof(array index variable) with sizeof(type).

memset() the correct data structure.


Commit By: jaltman



Revision: 19065
Changed Files:
U trunk/src/lib/krb5/os/sendto_kdc.c
From: Ken Raeburn <raeburn@MIT.EDU>
Subject: Re: [krbdev.mit.edu #5394] krb5-1.6: segfault on password change
Date: Thu, 18 Jan 2007 10:41:51 -0500
To: rt@krbdev.mit.edu
RT-Send-Cc:
On Jan 18, 2007, at 05:45, Public Submitter via RT wrote:
Show quoted text
> Getting segfault when trying to change the password.
>
> The reason is a typo in a memset call and an use of an uninizialied
> variable in lib/krb5/os/sendto_kdc.c

Tom and I were looking at this the other day. The uninitialized
variable shouldn't matter if it's only used in a sizeof expression.
The argument to sizeof isn't evaluated (except in the case of C99
variable-length arrays); only its type is needed. (Though it is
probably tidier to use something like sizeof(array[0]) and drop the
variable reference altogether.)

The memset bug would probably explain the problem, though...

Ken
From: tlyu@mit.edu
Subject: SVN Commit
pull up r19065 from trunk

r19065@cathode-dark-space: jaltman | 2007-01-18 06:35:33 -0500
ticket: 5394
tags: pullup

sendto_kdc.c: use of a variable index into a dynamically
allocated array to determine the sizeof() an object makes
it unclear what type of object is involved. It also requires
a runtime check instead of a compile time replacement.
Not to mention that it could lead to the evaluation of an
uninitialized variable as was done in this case. Replace
sizeof(array index variable) with sizeof(type).

memset() the correct data structure.




Commit By: tlyu



Revision: 19111
Changed Files:
_U branches/krb5-1-6/
U branches/krb5-1-6/src/lib/krb5/os/sendto_kdc.c