1 Return-Path: <matthias.guedemann@ovgu.de>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 76BB9431FD0
\r
6 for <notmuch@notmuchmail.org>; Wed, 25 May 2011 05:28:02 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id NofoDNma88BT for <notmuch@notmuchmail.org>;
\r
16 Wed, 25 May 2011 05:28:01 -0700 (PDT)
\r
17 Received: from mail.uni-magdeburg.de (mail.uni-magdeburg.de [141.44.1.10])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 90302431FB6
\r
19 for <notmuch@notmuchmail.org>; Wed, 25 May 2011 05:28:01 -0700 (PDT)
\r
20 Received: from pc44es141.cs.uni-magdeburg.de ([141.44.32.169]:1042)
\r
21 by mail.uni-magdeburg.de with esmtp (EXIM Version 4.69)
\r
22 id 1QPDBr-0005wf-Hy; Wed, 25 May 2011 14:27:59 +0200
\r
23 From: Matthias Guedemann <matthias.guedemann@ovgu.de>
\r
24 To: notmuch@notmuchmail.org
\r
25 Subject: [PATCH] fixed return value check of sysoncf in
\r
26 get_name_from_passwd_file / get_username_from_passwd_file
\r
27 User-Agent: Notmuch/0.5-145-gb6862c7 (http://notmuchmail.org) Emacs/23.2.1
\r
28 (x86_64-pc-dragonfly)
\r
29 Date: Wed, 25 May 2011 14:27:55 +0200
\r
30 Message-ID: <86mxibezhw.fsf@pc44es141.cs.uni-magdeburg.de>
\r
32 Content-Type: text/plain; charset=us-ascii
\r
33 X-Scan-Signature: 9b68607b0208bbe48ed39d5bb3438c68
\r
34 X-BeenThere: notmuch@notmuchmail.org
\r
35 X-Mailman-Version: 2.1.13
\r
37 List-Id: "Use and development of the notmuch mail system."
\r
38 <notmuch.notmuchmail.org>
\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
42 List-Post: <mailto:notmuch@notmuchmail.org>
\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
46 X-List-Received-Date: Wed, 25 May 2011 12:28:02 -0000
\r
49 When trying to port notmuch to DragonFlyBSD I found it core dumped
\r
50 immediately. The reason was that the "sysconf(_SC_GETPW_R_SIZE_MAX)"
\r
51 call returned -1 which is used for talloc memory allocation. The check
\r
52 was there but was done _after_ the allocation, the attached patch fixes
\r
59 diff --git a/notmuch-config.c b/notmuch-config.c
\r
60 index d86c042..6e4c5c4 100644
\r
61 --- a/notmuch-config.c
\r
62 +++ b/notmuch-config.c
\r
63 @@ -109,13 +109,15 @@ notmuch_config_destructor (notmuch_config_t *config)
\r
65 get_name_from_passwd_file (void *ctx)
\r
67 - long pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
\r
68 - char *pw_buf = talloc_zero_size (ctx, pw_buf_size);
\r
71 struct passwd passwd, *ignored;
\r
75 + pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
\r
76 if (pw_buf_size == -1) pw_buf_size = 64;
\r
77 + pw_buf = talloc_size (ctx, pw_buf_size);
\r
79 while ((e = getpwuid_r (getuid (), &passwd, pw_buf,
\r
80 pw_buf_size, &ignored)) == ERANGE) {
\r
81 @@ -142,13 +144,16 @@ get_name_from_passwd_file (void *ctx)
\r
83 get_username_from_passwd_file (void *ctx)
\r
85 - long pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
\r
86 - char *pw_buf = talloc_zero_size (ctx, pw_buf_size);
\r
89 struct passwd passwd, *ignored;
\r
93 + pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
\r
94 if (pw_buf_size == -1) pw_buf_size = 64;
\r
95 + pw_buf = talloc_zero_size (ctx, pw_buf_size);
\r
97 while ((e = getpwuid_r (getuid (), &passwd, pw_buf,
\r
98 pw_buf_size, &ignored)) == ERANGE) {
\r
99 pw_buf_size = pw_buf_size * 2;
\r