Given $a, it suffices to show that $f(x)=\alpha x+\beta$ on $[c,d]$ for some $\alpha,\beta$. Firstly, we can choose $\alpha,\beta$, such that for $g(x)=f(x)-\alpha x-\beta$, $g(c)=g(d)=0$. Since $g$ satisfies the same property with $f$, it suffices to show that $g=0$ on $[c,d]$.
Given $\lambda>0$, let $g_\lambda(x)=g(x)+\lambda(x-c)(x-d)$. Then $g_\lambda(c)=g_\lambda(d)=0$, and
$g_\lambda(x+2h)-2g_\lambda(x+h)+g_\lambda(x)=g(x+2h)-2g(x+h)+g(x)+2\lambda h^2.$ Then for $\epsilon=\lambda$, there exists $\delta>0$, such that when $|h|<\delta$, for any $x\in[c,d]$,
$g_\lambda(x+h)<\frac{1}{2}(g_\lambda(x)+g_\lambda(x+2h)).$ It implies that the maximum of $g_\lambda$ on $[c,d]$ cannot be attained in the interior $(c,d)$, i.e. $g_\lambda(x)\le 0$ on $[c,d]$. Since $\lambda$ is arbitrary, it follows that $g\le 0$ on $[c,d]$. Since the same argument works when $g$ is replaced by $-g$, $g=0$ on $[c,d]$.