Semantic versioning is hard; let's go build a rocket

Wow! I found another bug from the depths of time [1] in mod_blog [2], or rather, CGI (Common Gateway Interface)Lib [3], 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 [4], 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() [5] 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 [6] 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 [7], 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.

[1] /boston/2025/03/01.1
[2] https://github.com/spc476/mod_blog
[3] https://github.com/spc476/CGILib
[4] /boston/2025/11/30.1
[5] https://github.com/spc476/CGILib/blob/814cd23de1e6e33d7cc148913833f0175925c33a/src/Pair/PairNew.c#L74
[6] https://semver.org/
[7] https://idioms.thefreedictionary.com/on+the+gripping+hand
Gemini Mention this post
Contact the author