commit bfd30182c6619a969c33209accdca10d77af39f0 from: Tracey Emery date: Fri Jan 24 23:40:15 2020 UTC increase colorize buffer and don't crash on NULL strncmp/strlen commit - 05ce9a79810689c2365ff7f3a159f1b736f9f06b commit + bfd30182c6619a969c33209accdca10d77af39f0 blob - bb029b71cf4095537180a0de43f32d6d9e2fac4d blob + 8428efb9bfb5bc0b42eb6fa2a14059fc8c2e74d1 --- gotweb/gotweb.c +++ gotweb/gotweb.c @@ -1318,7 +1318,6 @@ gw_get_diff(struct gw_trans *gw_trans, struct gw_heade error = got_object_get_type(&obj_type, header->repo, id2); if (error) goto done; - switch (obj_type) { case GOT_OBJ_TYPE_BLOB: error = got_diff_objects_as_blobs(id1, id2, NULL, NULL, 3, 0, @@ -1341,7 +1340,7 @@ gw_get_diff(struct gw_trans *gw_trans, struct gw_heade fseek(f, 0, SEEK_SET); - while ((fgets(buf, 128, f)) != NULL) { + while ((fgets(buf, 2048, f)) != NULL) { n_buf = buf; while (*n_buf == '\n') n_buf++; @@ -1350,6 +1349,9 @@ gw_get_diff(struct gw_trans *gw_trans, struct gw_heade *newline = ' '; buf_color = gw_colordiff_line(gw_html_escape(n_buf)); + if (buf_color == NULL) + continue; + error = buf_puts(&newsize, diffbuf, buf_color); if (error) return NULL; @@ -2448,6 +2450,8 @@ gw_colordiff_line(char *buf) if (error) return NULL; + if (buf == NULL) + return NULL; if (strncmp(buf, "-", 1) == 0) color = "diff_minus"; if (strncmp(buf, "+", 1) == 0)