Sunday, November 30, 2025
Semantic versioning is hard; let's go build a rocket
Wow!
I found another bug from the depths of time in mod_blog,
or rather, CGILib,
which mod_blog uses.
And again,
this goes back right when I first wrote the code,
possibly back in the late 1990s.
And again,
it's amazing that it took me this long (less than an hour ago) to trigger it!
When I made my previous post,
the title came out incorrectly as “Error ID10T” when it should have been “Error ID10T: PEBKAC”.
Somehow,
any text after the colon was being swallowed up somewhere.
It didn't take long to find the culpret in the function PairNew() and this bit of code:
src = *psrc;
p = todelim(src,&sname,delim,eos);
name = malloc(sname + 1);
if (name == NULL)
return NULL;
memcpy(name,src,sname);
name[sname] = '\0';
if (*p == delim)
{
src = p + 1;
p = todelim(src,&svalue,delim,eos); // WRONG!
}
else
svalue = 0;
This function is used to parse a header line like Title: Error ID10T: PEBKAC and turn it into two values,
TITLE and Error ID10T: PEBKAC.
It's the line labeled “wrong” that points to the problem—I was checking for another occurance of delim
(in this case, it's a colon)
and ignoring anything past that when it shouldn't.
Sigh.
Like most bugs, the fix is easy, but what I do next is difficult. I (try to) use semantic versioning for CGILib, although there are two issues here—one, this is a bug so obviously the fixed version should be 8.0.8, but on the other hand, this introduces an incompatible change so the next version should be 9.0.0. On the gripping hand, it changes what I consider incorrect behavior and aligns the function to better reflect its name, so maybe version 8.0.8?
I think for CGILib this is largely academic, as I don't think anyone really uses the library except me. I shall have to think on this one.
![Oh Chrismtas Tree! My Christmas Tree! Rise up and hear the bells! [Self-portrait with a Christmas Tree] Oh Chrismtas Tree! My Christmas Tree! Rise up and hear the bells!](https://www.conman.org/people/spc/about/2025/1203.t.jpg)