From 7752d16f0671eaebb141911f735f4d6869cfc95f Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 4 Jan 2003 13:33:24 +0000 Subject: [PATCH] Fix more strncpys git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@263 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/ChangeLog | 5 ++-- bacula/ReleaseNotes | 22 ++++++++++++------ bacula/kernstodo | 43 +++++++++++++++++------------------ bacula/src/cats/sql_create.c | 3 +-- bacula/src/cats/sql_get.c | 6 ++--- bacula/src/cats/sqlite.c | 3 +-- bacula/src/dird/dird_conf.c | 2 +- bacula/src/dird/job.c | 2 +- bacula/src/dird/ua_output.c | 12 ++++------ bacula/src/dird/ua_status.c | 2 +- bacula/src/findlib/find_one.c | 4 ++-- bacula/src/lib/message.c | 3 +-- bacula/src/stored/acquire.c | 1 + bacula/src/version.h | 4 ++-- 14 files changed, 56 insertions(+), 56 deletions(-) diff --git a/bacula/ChangeLog b/bacula/ChangeLog index d908612815..e24a7f8f44 100644 --- a/bacula/ChangeLog +++ b/bacula/ChangeLog @@ -1,5 +1,4 @@ -2002-mm-dd Version 1.28 (not yet released) - +2003-01-04 Version 1.28 released General: - Implemented Bare Metal Recovery for Linux and manual procedures for Solaris - Now using only a single technotes file kes-1.28 and will add to @@ -13,6 +12,8 @@ General: tape drivers. Changes submitted this submission: +04Jan03 +- Add cygreadline5.dll to Win32 release -- needed for console 03Jan03 - Add scripts make_catalog_backup and delete_catalog_backup that makes and deletes an ASCII copy of the catalog for backup. An example of how diff --git a/bacula/ReleaseNotes b/bacula/ReleaseNotes index e0be1a3e46..d1b625f6d8 100644 --- a/bacula/ReleaseNotes +++ b/bacula/ReleaseNotes @@ -1,6 +1,6 @@ Release Notes for Bacula 1.28 - Bacula code: Total files = 226 Total lines = 61,863 (*.h *.c *.in) + Bacula code: Total files = 228 Total lines = 62,042 (*.h *.c *.in) Major Changes this Release: - Bare Metal Recovery mostly automated for Linux systems and @@ -10,11 +10,12 @@ Major Changes this Release: - Schedule permits specification of 1st, 2nd, ... week e.g. 1st Sun ... -Minor Changes this Release: +Other Changes this Release: - Allow backup of raw partitions. - Fixed Restore options (never,ifnewer, ...). They now work. -- New bidirectional timed pipe mechanism for running child processes - permits better error messages. +- Added a --enable-client-only option that will cause "make" to only + build the File daemon and the libraries it needs. +- Documented how to save the Catalog database (with included script). - Faster Storage daemon initialization (using pthreads) - Unlimited devices in Storage daemon (previously hard coded to 20). - Fixed bug that recognized only the last option specified on Include record. @@ -28,9 +29,16 @@ Minor Changes this Release: - User supplied script for Sun-desktop autoloader (examples/devices). - Added configure options for building static versions of the daemons and the console program. -- Added a --enable-client-only option that will cause "make" to only - build the File daemon and the libraries it needs. -- Documented how to save the Catalog database (with included script). +- New bidirectional timed pipe mechanism for running child processes + permits better error messages. +- Removed last restrictions on filename length for catalog items. Previous + maximum was 500 chars for path and 500 chars for filename. Now unlimited. +- Improvements all over the code to prevent string overflows and to ensure + that copied strings are properly terminated. +- Improved handling of 64 bit integers especially concerning the DB. +- Database now contains accurate tape file/block positions, and many other + DB items are more correctly handled. +- Improved bootstrap record generation (more detail). Items to note: - Nothing in particular. diff --git a/bacula/kernstodo b/bacula/kernstodo index b8c7bc9461..4adfb3f4bc 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -1,12 +1,10 @@ Kern's ToDo List - 01 January 2003 + 04 January 2003 Documentation to do: (a little bit at a time) - Document running a test version. -- Make sure restore options are documented - Document query file format. - Document static linking -- Document nofollow flag Testing to do: (painful) - that console command line options work @@ -17,14 +15,16 @@ For 1.28 release: - Figure out how to allow multiple simultaneous file Volumes on a single device. - Why are save/restore of device different sizes (sparse?) -- Backup of raw partitions +- Make sure differential handled correctly For 1.29 release: +- Cancel does not work for restore in FD. +- Restore to a particular time -- e.g. before date, after date. - Implement SHA1 - Implement disk spooling - Implement finer multiprocessing options. - Solaris -I on tar for include list -- Add whereln to where or not where absolute links +- Add whereabslinks to where or not where absolute links - Figure out some way to automatically backup all local partitions - Enable avoid backing up archive device (findlib/find_one.c:128) - Implement FileOptions (see end of this document) @@ -32,7 +32,6 @@ For 1.29 release: - Make hash table for linked files in findlib/find_one.c:161 - Make bcopy read through bad tape records. - Need a verbose mode in restore, perhaps to bsr. -- Should we dump a SOS when starting a new tape? - bscan without -v is too quiet -- perhaps show jobs. - Add code to reject whole blocks if not wanted on restore. - Implement multiple simultaneous file Volumes on a single device. @@ -61,16 +60,12 @@ For 1.29 release: - Restore program that errors in SD due to no tape reports OK incorrectly in output. - After unmount, if restore job started, ask to mount. -- Fix db_get_fileset in cats/sql_get.c for multiple records. -- Fix catalog filename truncation in sql_get and sql_create. Use - only a single filename split routine. - Make Restore report an error if FD or SD term codes are not OK. - Convert all %x substitution variables, which are hard to remember and read to %(variable-name). Idea from TMDA. - Add JobLevel in FD status (but make sure it is defined). - Make Pool resource handle Counter resources. - Remove NextId for SQLite. Optimize. -- Fix gethostbyname() to use gethostbyname_r() - Strip trailing / from Include - Move all SQL statements into a single location. - Cleanup db_update_media and db_update_pool @@ -84,7 +79,6 @@ For 1.29 release: - Add Client FS/OS id (Linux, Win95/98, ...). - Test a second language e.g. french. - Compare tape to Client files (attributes, or attributes and data) -- Restore to a particular time -- e.g. before date, after date. - Make all database Ids 64 bit. - Write an applet for Linux. - Add estimate to Console commands @@ -105,14 +99,13 @@ For 1.29 release: - Fix Win2000 error with no messages during startup. - Events : tape has more than xxx bytes. - Restrict characters permitted in a Resource name. -- Complete code in Bacula Resources -- this will permit +- Complete code in Bacula Resources -- this will permit reading a new config file at any time. - Handle ctl-c in Console - Implement LabelTemplate (at least first cut). - Implement script driven addition of File daemon to config files. - Think about how to make Bacula work better with File (non-tape) archives. -- see setgroup and user for Bacula p4-5 of stunnel.c - Implement new serialize subroutines send(socket, "string", &Vol, "uint32", &i, NULL) - Audit all UA commands to ensure that we always prompt where possible. @@ -122,7 +115,6 @@ For 1.29 release: - Make database type selectable by .conf files i.e. at runtime - gethostbyname failure in bnet_connect() continues generating errors -- should stop. -- Add HOST to Volume label. - Set flag for uname -a. Add to Volume label. - Implement throttled work queue. - Check for EOT at ENOSPC or EIO or ENXIO (unix Pc) @@ -152,8 +144,6 @@ For 1.29 release: - Make bcopy copy with a single tape drive. - Permit changing ownership during restore. -- Restore should get Device and Pool information from - job record rather than from config. - Autolabel should be specified by DIR instead of SD. - Find out how to get the system tape block limits, e.g.: Apr 22 21:22:10 polymatou kernel: st1: Block limits 1 - 245760 bytes. @@ -187,6 +177,8 @@ For 1.29 release: ===== - FD sends unsaved file list to Director at end of job (see RFC below). +- File daemon should build list of files skipped, and then + at end of save retry and report any errors. - Write a Storage daemon that uses pipes and standard Unix programs to write to the tape. See afbackup. @@ -203,18 +195,13 @@ For 1.29 release: if tape is not valid. - Verify from Volume - Ensure that /dev/null works -- File daemon should build list of files skipped, and then - at end of save retry and report any errors. - Need report class for messages. Perhaps report resource where report=group of messages - enhance scan_attrib and rename scan_jobtype, and fill in code for "since" option -- Need to save contents of FileSet to tape? - Director needs a time after which the report status is sent anyway -- or better yet, a retry time for the job. Don't reschedule a job if previous incarnation is still running. -- Figure out how to save the catalog (possibly a special FileSet). -- Figure out how to restore the catalog. - Some way to automatically backup everything is needed???? - Need a structure for pending actions: - buffered messages @@ -254,7 +241,7 @@ Projects: last update 27 November 2002 Item 1: Multiple simultaneous Jobs. (done) -Done +Done -- Restore part needs better implementation to work correctly What: Permit multiple simultaneous jobs in Bacula. @@ -707,4 +694,16 @@ Done: (see kernsdone for more) - Implement ./configure --with-client-only - Finish up static linking - that restore options work in FD +- Backup of raw partitions +- Document nofollow flag +- Make sure restore options are documented +- Should we dump a SOS when starting a new tape? (no -- too complicated) +- Fix gethostbyname() to use gethostbyname_r() -- no added mutex +- Add HOST to Volume label. +- Need to save contents of FileSet to tape? -- no not now +- Fix db_get_fileset in cats/sql_get.c for multiple records. +- Fix catalog filename truncation in sql_get and sql_create. Use + only a single filename split routine. +- Figure out how to save the catalog (possibly a special FileSet). +- Figure out how to restore the catalog. diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index be30de82b2..4747c20f5d 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -306,8 +306,7 @@ int db_create_client_record(B_DB *mdb, CLIENT_DBR *cr) } cr->ClientId = atoi(row[0]); if (row[1]) { - strncpy(cr->Uname, row[1], sizeof(cr->Uname)-2); - cr->Uname[sizeof(cr->Uname)-1] = 0; + bstrncpy(cr->Uname, row[1], sizeof(cr->Uname)); } else { cr->Uname[0] = 0; /* no name */ } diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index a063cc2618..f3f0539987 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -186,10 +186,8 @@ File.FilenameId=%u", fdbr->JobId, fdbr->PathId, fdbr->FilenameId); Mmsg1(&mdb->errmsg, _("Error fetching row: %s\n"), sql_strerror(mdb)); } else { fdbr->FileId = (FileId_t)str_to_int64(row[0]); - strncpy(fdbr->LStat, row[1], sizeof(fdbr->LStat)); - fdbr->LStat[sizeof(fdbr->LStat)] = 0; - strncpy(fdbr->MD5, row[2], sizeof(fdbr->MD5)); - fdbr->MD5[sizeof(fdbr->MD5)] = 0; + bstrncpy(fdbr->LStat, row[1], sizeof(fdbr->LStat)); + bstrncpy(fdbr->MD5, row[2], sizeof(fdbr->MD5)); stat = 1; } } else { diff --git a/bacula/src/cats/sqlite.c b/bacula/src/cats/sqlite.c index d26c69dea6..2fe91481ca 100644 --- a/bacula/src/cats/sqlite.c +++ b/bacula/src/cats/sqlite.c @@ -205,8 +205,7 @@ int db_next_index(B_DB *mdb, char *table, char *index) db_unlock(mdb); return 0; } - strncpy(index, row[0], 28); - index[28] = 0; + bstrncpy(index, row[0], 28); sql_free_result(mdb); Mmsg(&mdb->cmd, diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 2f9ca4854e..91f3d11475 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -22,7 +22,7 @@ * Version $Id$ */ /* - Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker + Copyright (C) 2000-2003 Kern Sibbald and John Walker This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index a7f7b367c6..2c1055a254 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -293,7 +293,7 @@ void create_unique_job_name(JCR *jcr, char *base_name) localtime_r(&now, &tm); /* Use only characters that are permitted in Windows filenames */ strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M.%S", &tm); - strncpy(name, base_name, sizeof(name)); + bstrncpy(name, base_name, sizeof(name)); name[sizeof(name)-22] = 0; /* truncate if too long */ sprintf(jcr->Job, "%s.%s", name, dt); /* add date & time */ /* Convert spaces into underscores */ diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index 975970e357..a61feeb4de 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -233,8 +233,7 @@ int listcmd(UAContext *ua, char *cmd) /* List JOB */ } else if (strcasecmp(ua->argk[i], _("job")) == 0 && ua->argv[i]) { - strncpy(jr.Job, ua->argv[i], MAX_NAME_LENGTH); - jr.Job[MAX_NAME_LENGTH-1] = 0; + bstrncpy(jr.Job, ua->argv[i], MAX_NAME_LENGTH); jr.JobId = 0; db_list_job_records(ua->db, &jr, prtit, ua); @@ -243,8 +242,7 @@ int listcmd(UAContext *ua, char *cmd) for (j=i+1; jargc; j++) { if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) { - strncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH); - jr.Job[MAX_NAME_LENGTH-1] = 0; + bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH); jr.JobId = 0; db_get_job_record(ua->db, &jr); jobid = jr.JobId; @@ -263,8 +261,7 @@ int listcmd(UAContext *ua, char *cmd) int done = FALSE; for (j=i+1; jargc; j++) { if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) { - strncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH); - jr.Job[MAX_NAME_LENGTH-1] = 0; + bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH); jr.JobId = 0; db_get_job_record(ua->db, &jr); jobid = jr.JobId; @@ -295,8 +292,7 @@ int listcmd(UAContext *ua, char *cmd) int done = FALSE; for (j=i+1; jargc; j++) { if (strcasecmp(ua->argk[j], _("job")) == 0 && ua->argv[j]) { - strncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH); - jr.Job[MAX_NAME_LENGTH-1] = 0; + bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH); jr.JobId = 0; db_get_job_record(ua->db, &jr); jobid = jr.JobId; diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 77a7be2540..a01ac3806f 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -8,7 +8,7 @@ */ /* - Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker + Copyright (C) 2000-2003 Kern Sibbald and John Walker This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/bacula/src/findlib/find_one.c b/bacula/src/findlib/find_one.c index b13a9da33f..597d2575e9 100755 --- a/bacula/src/findlib/find_one.c +++ b/bacula/src/findlib/find_one.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker + Copyright (C) 2000-2003 Kern Sibbald and John Walker This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -218,7 +218,7 @@ find_one_file(FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt), void *pkt len = strlen(fname); namebuf_len = len + DEFAULT_NAMEBUF_LEN; namebuf = (char *)bmalloc(namebuf_len + 2); - strncpy(namebuf, fname, namebuf_len); + bstrncpy(namebuf, fname, namebuf_len); while (len >= 1 && namebuf[len - 1] == '/') len--; namebuf[len++] = '/'; diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index b5b4dd8ab9..a0079a6acb 100755 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -71,8 +71,7 @@ void my_name_is(int argc, char *argv[], char *name) char cpath[400], npath[400]; int len; - strncpy(my_name, name, sizeof(my_name)); - my_name[sizeof(my_name)-1] = 0; + bstrncpy(my_name, name, sizeof(my_name)); if (argc>0 && argv && argv[0]) { /* strip trailing filename and save exepath */ for (l=p=argv[0]; *p; p++) { diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 9f674d3eaf..d57b4f03b4 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -128,6 +128,7 @@ default_path: stat = 1; /* good return */ if ((dev->state & ST_TAPE) && vol->start_file > 0) { Dmsg1(200, "====== Got start_file = %d\n", vol->start_file); + Jmsg(jcr, M_INFO, 0, _("Forward spacing to file %d.\n"), vol->start_file); fsf_dev(dev, vol->start_file); } diff --git a/bacula/src/version.h b/bacula/src/version.h index ecd466b27b..5646b09bf7 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #define VERSION "1.28" #define VSTRING "1" -#define DATE "2 January 2003" -#define LSMDATE "02Jan03" +#define DATE "4 January 2003" +#define LSMDATE "04Jan03" /* Debug flags */ #define DEBUG 1 -- 2.39.5