Commit Diff
- Commit:
eb35d814a71cef3007900867c20d881fcd173039
- From:
- Omar Polo <op@omarpolo.com>
- Via:
- Thomas Adam <thomas@xteddy.org>
- Date:
- Message:
- got patch: guard against invalid (negative) line offsets under normal circumstances got-read-patch can't send negative line offsets; that's not an excuse not to guard the main process from those as well. This makes sure we bail out early instead of trying to apply the diff.
- Actions:
- Patch | Tree
--- lib/patch.c +++ lib/patch.c @@ -241,6 +241,10 @@ recv_patch(struct imsgbuf *ibuf, int *done, struct got memcpy(&hdr, imsg.data, sizeof(hdr)); if ((h = calloc(1, sizeof(*h))) == NULL) { err = got_error_from_errno("calloc"); + goto done; + } + if (h->old_from < 0 || h->new_from < 0) { + err = got_error(GOT_ERR_PRIVSEP_LEN); goto done; } h->old_from = hdr.oldfrom;