]> jfr.im git - irc.git/blame - software/RELEASES/ircservices/achurch.org/services/lists/ircservices/2004/004540.html
init
[irc.git] / software / RELEASES / ircservices / achurch.org / services / lists / ircservices / 2004 / 004540.html
CommitLineData
3bd189cb
JR
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
2<HTML>
3 <HEAD>
4 <TITLE> [IRCServices] Allocation error: ns unsuspend [retry]
5 </TITLE>
6 <LINK REL="Index" HREF="index.html" >
7 <LINK REL="made" HREF="mailto:ircservices%40ircservices.za.net?Subject=%5BIRCServices%5D%20Allocation%20error%3A%20ns%20unsuspend%20%5Bretry%5D&In-Reply-To=20040726120549.PHYF11275.mta09-svc.ntlworld.com%40excelsior">
8 <META NAME="robots" CONTENT="index,nofollow">
9 <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
10 <LINK REL="Previous" HREF="004539.html">
11 <LINK REL="Next" HREF="004541.html">
12 </HEAD>
13 <BODY BGCOLOR="#ffffff">
14 <H1>[IRCServices] Allocation error: ns unsuspend [retry]</H1>
15 <B>Andrew Church</B>
16 <A HREF="mailto:ircservices%40ircservices.za.net?Subject=%5BIRCServices%5D%20Allocation%20error%3A%20ns%20unsuspend%20%5Bretry%5D&In-Reply-To=20040726120549.PHYF11275.mta09-svc.ntlworld.com%40excelsior"
17 TITLE="[IRCServices] Allocation error: ns unsuspend [retry]">achurch at achurch.org
18 </A><BR>
19 <I>Mon Jul 26 22:29:50 PDT 2004</I>
20 <P><UL>
21 <LI>Previous message: <A HREF="004539.html">[IRCServices] Allocation error: ns unsuspend [retry]
22</A></li>
23 <LI>Next message: <A HREF="004541.html">[IRCServices] Allocation error: ns unsuspend [retry]
24</A></li>
25 <LI> <B>Messages sorted by:</B>
26 <a href="date.html#4540">[ date ]</a>
27 <a href="thread.html#4540">[ thread ]</a>
28 <a href="subject.html#4540">[ subject ]</a>
29 <a href="author.html#4540">[ author ]</a>
30 </LI>
31 </UL>
32 <HR>
33<!--beginarticle-->
34<PRE> I did see your original message--it's just that I've been going
35through the entire code to find and fix similar bugs as well. I have a
36sneaking suspicion that the expire-on-get design plays nasty games with
37pointers in the user record too, but as it hasn't seemed to cause any
38problems so far, I'm saving that bit of contemplation for 5.1 (which,
39incidentally, will also have similar use-after-free checks in the memory
40checking code).
41
42 At any rate, thanks for the report.
43
44 --Andrew Church
45 <A HREF="http://www.ircservices.za.net/mailman/listinfo/ircservices">achurch at achurch.org</A>
46 <A HREF="http://achurch.org/">http://achurch.org/</A>
47
48&gt;<i>Hi again,
49</I>&gt;<i>
50</I>&gt;<i>[ I sent this yesterday, but it seems it got put under another thread in the
51</I>&gt;<i>archive, and didn't actually get sent out to the list, so I'll send it again
52</I>&gt;<i>in case it gets missed :) ]
53</I>&gt;<i>
54</I>&gt;<i>I just noticed and patched another bug, quite similar to the last issue I
55</I>&gt;<i>posted about (&quot;Seg Fault/Bus Error on SQUIT&quot;:
56</I>&gt;<i><A HREF="http://www.ircservices.za.net/pipermail/ircservices/2004/003377.html">http://www.ircservices.za.net/pipermail/ircservices/2004/003377.html</A> ).
57</I>&gt;<i>
58</I>&gt;<i>Again, I noticed this one because free() is set up to write a pattern over
59</I>&gt;<i>memory as it is released on our services host. It wouldn't occur in most
60</I>&gt;<i>normal circumstances, but might do unpredictably, depending on a lot of
61</I>&gt;<i>factors, so ought to be fixed.
62</I>&gt;<i>
63</I>&gt;<i>The problem occurs when unsuspending a nickname that is part of a group in
64</I>&gt;<i>which no nickname has been used for longer than the NSExpire setting - or
65</I>&gt;<i>something along those lines.
66</I>&gt;<i>
67</I>&gt;<i>In modules/nickserv/util.c, unsuspend_nick() does this:
68</I>&gt;<i>
69</I>&gt;<i> ARRAY_FOREACH (i, ngi-&gt;nicks) {
70</I>&gt;<i> NickInfo *ni = get_nickinfo(ngi-&gt;nicks[i]);
71</I>&gt;<i> ...
72</I>&gt;<i> }
73</I>&gt;<i>
74</I>&gt;<i>get_nickinfo() will free (NickGroupInfo *)ngi under certain conditions
75</I>&gt;<i>(roughly as I described above), making the following attempts to dereference
76</I>&gt;<i>ngi crash the program:
77</I>&gt;<i>
78</I>&gt;<i> if (!ni) {
79</I>&gt;<i> module_log(&quot;unsuspend: unable to retrieve NickInfo
80</I>&gt;<i>for %s&quot;
81</I>&gt;<i> &quot; (nick group %u)&quot;, ngi-&gt;nicks[i], ngi-&gt;id);
82</I>&gt;<i> continue;
83</I>&gt;<i> }
84</I>&gt;<i>
85</I>&gt;<i>ngi would also be used in subsequent loops, so just changing the log message
86</I>&gt;<i>wouldn't be a solution.
87</I>&gt;<i>
88</I>&gt;<i>I didn't have a lot of time to investigate the best way to fix this, but
89</I>&gt;<i>here is the patch I came up with. It seems to do the job, but I would be
90</I>&gt;<i>grateful if anyone can advise something more suitable. (Lines beginning &quot;+&quot;
91</I>&gt;<i>were added; noexpire is just set to 1 before the loop, and restored
92</I>&gt;<i>afterwards, which stops the expiry check. Note that the NSSuspendGrace stuff
93</I>&gt;<i>only happens a few lines after the call to get_nickinfo(), so for that small
94</I>&gt;<i>time, nick groups can disappear.).
95</I>&gt;<i>
96</I>&gt;<i> void unsuspend_nick(NickGroupInfo *ngi, int set_time)
97</I>&gt;<i> {
98</I>&gt;<i> time_t now = time(NULL);
99</I>&gt;<i>+ int cache_noexpire = 0;
100</I>&gt;<i>
101</I>&gt;<i> if (!ngi-&gt;suspendinfo) {
102</I>&gt;<i> module_log(&quot;unsuspend: called on non-suspended nick group %u [%s]&quot;,
103</I>&gt;<i>
104</I>&gt;<i>...
105</I>&gt;<i>
106</I>&gt;<i> &quot; %u) to %ld&quot;, ngi-&gt;nicks[ngi-&gt;mainnick], ngi-&gt;id,
107</I>&gt;<i> (long)ngi-&gt;authset);
108</I>&gt;<i> }
109</I>&gt;<i>+ cache_noexpire = noexpire;
110</I>&gt;<i>+ noexpire = 1;
111</I>&gt;<i> ARRAY_FOREACH (i, ngi-&gt;nicks) {
112</I>&gt;<i> NickInfo *ni = get_nickinfo(ngi-&gt;nicks[i]);
113</I>&gt;<i> if (!ni) {
114</I>&gt;<i>
115</I>&gt;<i>...
116</I>&gt;<i>
117</I>&gt;<i> }
118</I>&gt;<i> }
119</I>&gt;<i> }
120</I>&gt;<i>+ noexpire = cache_noexpire;
121</I>&gt;<i> }
122</I>&gt;<i>
123</I>&gt;<i>
124</I>&gt;<i>/*************************************************************************/
125</I>&gt;<i>
126</I>&gt;<i>--
127</I>&gt;<i>Tom McIntyre
128</I>&gt;<i><A HREF="http://www.ircservices.za.net/mailman/listinfo/ircservices">chawmp at cyberarmy.net</A>
129</I>&gt;<i>
130</I>&gt;<i>
131</I>&gt;<i>
132</I>&gt;<i>------------------------------------------------------------------
133</I>&gt;<i>To unsubscribe or change your subscription options, visit:
134</I>&gt;<i><A HREF="http://www.ircservices.za.net/mailman/listinfo/ircservices">http://www.ircservices.za.net/mailman/listinfo/ircservices</A>
135</I>
136
137</PRE>
138
139<!--endarticle-->
140 <HR>
141 <P><UL>
142 <!--threads-->
143 <LI>Previous message: <A HREF="004539.html">[IRCServices] Allocation error: ns unsuspend [retry]
144</A></li>
145 <LI>Next message: <A HREF="004541.html">[IRCServices] Allocation error: ns unsuspend [retry]
146</A></li>
147 <LI> <B>Messages sorted by:</B>
148 <a href="date.html#4540">[ date ]</a>
149 <a href="thread.html#4540">[ thread ]</a>
150 <a href="subject.html#4540">[ subject ]</a>
151 <a href="author.html#4540">[ author ]</a>
152 </LI>
153 </UL>
154
155</body></html>