~mil/sxmo-tickets#499: 
mnc: If the crontab doesnt end with a newline, mnc crashes

panic: runtime error: slice bounds out of range [:5] with capacity 1

goroutine 1 [running]:
main.main()
	/home/mrrabbit/.local/git/sxmo-build/build-sxmo-dev/mnc/mnc.go:37 +0x304


*/30 * * * * sxmo_rtcwake.sh /home/mrrabbit/.local/scripts/newsup
Status
REPORTED
Submitter
~anjan
Assigned to
No-one
Submitted
2 years ago
Updated
1 year, 2 months ago
Labels
No labels applied.

~noneofyourbusiness 1 year, 2 months ago

small test to reproduce it is

printf '%s\n\n' '* * * * * abc' | mnc

ticket title needs an update

~noneofyourbusiness 1 year, 2 months ago*

Also, if I'm reading this correctly in the section INPUT FILES, that '/' is non-POSIX.

https://www.man7.org/linux/man-pages/man1/crontab.1p.html

* and elements are fine, no /

~noneofyourbusiness 1 year, 2 months ago*

I think the error is here: https://pkg.go.dev/strings#TrimSpace

It trims whitespace, including newlines.

https://git.sr.ht/~anjan/mnc/tree/master/item/mnc.go#L36

You want to just separate the fields by (whitespace), and then trim leading/trailing whitespace

Register here or Log in to comment, or comment via email.