mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Zvi Gilboa <zg7s@eservices.virginia.edu>
To: <musl@lists.openwall.com>
Subject: crypt_data: structure size in crypt.c vs. crypt.h
Date: Thu, 11 Apr 2013 18:42:26 -0400	[thread overview]
Message-ID: <51673C52.3020108@eservices.virginia.edu> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 840 bytes --]

Greetings,

Looking at crypt.c and crypt.h, I was wondering whether having 
different-size /crypt_data/ structures was intentional, and if so, for 
what reason.  At the moment, the declarations are (and see also the 
attached code):

/<crypt.h>/
struct crypt_data {
     int initialized;
     char *__buf[256]*;
}; /* 260 bytes when sizeof(int)==4 */

/<crypt.c>/
char *__crypt_r(const char *, const char *, *struct crypt_data **);

char *crypt(const char *key, const char *salt)
{
     static char *buf[128]*;
     return __crypt_r(key, salt, *(struct crypt_data *)buf*);
     /* when sizeof(int)==4, this leaves __buf with 124 bytes. */
}


On that note: since the /initialized /member is (currently) never 
referenced by name, adding a comment about that to the code might help 
readers who are yet to be initiated:)

Best regards,
Zvi


[-- Attachment #1.2: Type: text/html, Size: 1359 bytes --]

[-- Attachment #2: crypt_data_struct_size.c --]
[-- Type: text/x-csrc, Size: 264 bytes --]

#include <stdio.h>
#include <crypt.h>

int main(void) {
	struct crypt_data cd;
	static char buf[128];
	
	printf("sizeof(int)\t\t\t%zu\n", sizeof(int));
	printf("sizeof(crypt_data)\t\t%zu\n", sizeof(cd));
	printf("sizeof(static char[128])\t%zu\n", sizeof(buf));
}


             reply	other threads:[~2013-04-11 22:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-11 22:42 Zvi Gilboa [this message]
2013-04-11 22:59 ` Rich Felker
2013-04-12  0:03   ` Zvi Gilboa
2013-04-12  1:42     ` Rich Felker
2013-04-12  2:18       ` Zvi Gilboa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51673C52.3020108@eservices.virginia.edu \
    --to=zg7s@eservices.virginia.edu \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).