X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/e7c67065c060d500eba8d073da9568db2c658aad..1c60d219472b3de0080cda807b014d011e3b5ccb:/tls.c diff --git a/tls.c b/tls.c index 425d7019..cd4e26de 100644 --- a/tls.c +++ b/tls.c @@ -2,11 +2,11 @@ * Trivial ls for comparing two directories after running an rsync. * * Copyright (C) 2001, 2002 Martin Pool - * Copyright (C) 2003, 2004, 2005 Wayne Davison + * Copyright (C) 2003-2007 Wayne Davison * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License version - * 2 as published by the Free Software Foundation. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -74,7 +74,7 @@ static void list_file(const char *fname) buf.st_mode &= ~0777; buf.st_mtime = (time_t)0; buf.st_uid = buf.st_gid = 0; - strcpy(linkbuf, " -> "); + strlcpy(linkbuf, " -> ", sizeof linkbuf); /* const-cast required for silly UNICOS headers */ len = readlink((char *) fname, linkbuf+4, sizeof(linkbuf) - 4); if (len == -1) @@ -91,16 +91,16 @@ static void list_file(const char *fname) if (buf.st_mtime) { mt = gmtime(&buf.st_mtime); - sprintf(datebuf, "%04d-%02d-%02d %02d:%02d:%02d", + snprintf(datebuf, sizeof datebuf, + "%04d-%02d-%02d %02d:%02d:%02d", (int)mt->tm_year + 1900, (int)mt->tm_mon + 1, (int)mt->tm_mday, (int)mt->tm_hour, (int)mt->tm_min, (int)mt->tm_sec); - } else { - strcpy(datebuf, " "); - } + } else + strlcpy(datebuf, " ", sizeof datebuf); /* TODO: Perhaps escape special characters in fname? */ @@ -120,7 +120,7 @@ int main(int argc, char *argv[]) { if (argc < 2) { - fprintf(stderr, "usage: " PROGRAM " DIR ...\n" + fprintf(stderr, "usage: " PROGRAM " FILE ...\n" "Trivial file listing program for portably checking rsync\n"); return 1; }