[20542] in Kerberos_V5_Development

home help back first fref pref prev next nref lref last post

change_password resource cleanup?

daemon@ATHENA.MIT.EDU (Joonas Tuomisto)
Sat Jun 28 02:00:58 2025

MIME-Version: 1.0
From: Joonas Tuomisto <jootuom@gmail.com>
Date: Sat, 28 Jun 2025 07:50:54 +0300
Message-ID: <CALuYaDz3-DjXTqsN+yz+PDKoALq0nzETcxmnLBEw6cN4L5zgCQ@mail.gmail.com>
To: krbdev@mit.edu
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: krbdev-bounces@mit.edu

Hello,

I'm not really a C developer. As my first C "project", I'm working on
something using krb5_change_password(). Manual memory management is tricky!

Question:

krb5_change_password() returns the result_code_string and result_string
krb5_data structures. Are you supposed to free() them - or I suppose more
specifically, krb5_free_data() them after use?

The documentation for krb5_chpw_message() explicitly calls out that you
should krb5_free_string() its message_out. For krb5_change_password() it
does not.

Secondarily:

Are these krb5_free_* functions always safe to call or should you only
assume the structs exist (and require cleanup) when e.g.
krb5_change_password() returns with result_code set?

My code now has if (retval) ... if (result_code) ... sprinkled and I can
already see myself how you could easily end up with resource leaks with C
and different code paths. A common cleanup path helps.

Thanks!
_______________________________________________
krbdev mailing list             krbdev@mit.edu
https://mailman.mit.edu/mailman/listinfo/krbdev

home help back first fref pref prev next nref lref last post