buf shouldn't be declared here.