"Fossies" - the Fresh Open Source Software Archive

Member "passwdqc-2.0.3/pam_macros.h" (23 Jun 2023, 851 Bytes) of package /linux/privat/passwdqc-2.0.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "pam_macros.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * These macros are partially based on Linux-PAM's <security/_pam_macros.h>,
    3  * which were organized by Cristian Gafton and I believe are in the public
    4  * domain.
    5  *
    6  * - Solar Designer
    7  */
    8 
    9 #ifndef PAM_PASSWDQC_MACROS_H__
   10 #define PAM_PASSWDQC_MACROS_H__
   11 
   12 #include <string.h>
   13 #include <stdlib.h>
   14 
   15 #define pwqc_overwrite_string(x) \
   16 do { \
   17     if (x) \
   18         memset((x), 0, strlen(x)); \
   19 } while (0)
   20 
   21 #define pwqc_drop_mem(x) \
   22 do { \
   23     if (x) { \
   24         free(x); \
   25         (x) = NULL; \
   26     } \
   27 } while (0)
   28 
   29 #define pwqc_drop_pam_reply(/* struct pam_response* */ reply, /* int */ replies) \
   30 do { \
   31     if (reply) { \
   32         int reply_i; \
   33 \
   34         for (reply_i = 0; reply_i < (replies); ++reply_i) { \
   35             pwqc_overwrite_string((reply)[reply_i].resp); \
   36             pwqc_drop_mem((reply)[reply_i].resp); \
   37         } \
   38         pwqc_drop_mem(reply); \
   39     } \
   40 } while (0)
   41 
   42 #endif /* PAM_PASSWDQC_MACROS_H__ */