tftp-utils.c (302408) | tftp-utils.c (339051) |
---|---|
1/* 2 * Copyright (C) 2008 Edwin Groothuis. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 10 unchanged lines hidden (view full) --- 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 */ 25 26#include <sys/cdefs.h> | 1/* 2 * Copyright (C) 2008 Edwin Groothuis. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 10 unchanged lines hidden (view full) --- 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 */ 25 26#include <sys/cdefs.h> |
27__FBSDID("$FreeBSD: stable/11/libexec/tftpd/tftp-utils.c 241720 2012-10-19 05:43:38Z ed $"); | 27__FBSDID("$FreeBSD: stable/11/libexec/tftpd/tftp-utils.c 339051 2018-10-01 15:47:34Z asomers $"); |
28 29#include <sys/socket.h> 30#include <sys/stat.h> 31 32#include <netinet/in.h> 33#include <arpa/tftp.h> 34 35#include <stdarg.h> --- 227 unchanged lines hidden (view full) --- 263 { RP_TOOBIG, "Too many data bytes" }, 264 { RP_NONE, NULL } 265}; 266 267char * 268rp_strerror(int error) 269{ 270 static char s[100]; | 28 29#include <sys/socket.h> 30#include <sys/stat.h> 31 32#include <netinet/in.h> 33#include <arpa/tftp.h> 34 35#include <stdarg.h> --- 227 unchanged lines hidden (view full) --- 263 { RP_TOOBIG, "Too many data bytes" }, 264 { RP_NONE, NULL } 265}; 266 267char * 268rp_strerror(int error) 269{ 270 static char s[100]; |
271 size_t space = sizeof(s); |
|
271 int i = 0; 272 273 while (rp_errors[i].desc != NULL) { 274 if (rp_errors[i].error == error) { | 272 int i = 0; 273 274 while (rp_errors[i].desc != NULL) { 275 if (rp_errors[i].error == error) { |
275 strcpy(s, rp_errors[i].desc); | 276 strlcpy(s, rp_errors[i].desc, space); 277 space -= strlen(rp_errors[i].desc); |
276 } 277 i++; 278 } 279 if (s[0] == '\0') 280 sprintf(s, "unknown (error=%d)", error); 281 return (s); 282} 283 --- 36 unchanged lines hidden --- | 278 } 279 i++; 280 } 281 if (s[0] == '\0') 282 sprintf(s, "unknown (error=%d)", error); 283 return (s); 284} 285 --- 36 unchanged lines hidden --- |