From de2e1d3b697cf0f13b06a840290b42798ed477b5 Mon Sep 17 00:00:00 2001 From: reinelt Date: Mon, 30 Jan 2006 12:53:08 +0000 Subject: [lcd4linux @ 2006-01-30 12:53:07 by reinelt] replaced strncpy with strcpy where possible git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@631 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- cfg.c | 24 +++++++++++++++++++----- evaluator.c | 13 ++++++++----- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/cfg.c b/cfg.c index 66dbd98..f0e483a 100644 --- a/cfg.c +++ b/cfg.c @@ -1,4 +1,4 @@ -/* $Id: cfg.c,v 1.47 2005/05/08 04:32:43 reinelt Exp $^ +/* $Id: cfg.c,v 1.48 2006/01/30 12:53:07 reinelt Exp $^ * * config file stuff * @@ -23,6 +23,9 @@ * * * $Log: cfg.c,v $ + * Revision 1.48 2006/01/30 12:53:07 reinelt + * replaced strncpy with strcpy where possible + * * Revision 1.47 2005/05/08 04:32:43 reinelt * CodingStyle added and applied * @@ -334,6 +337,7 @@ static char *strip(char *s, const int strip_comments) while (isblank(*s)) s++; + for (p = s; *p; p++) { if (*p == '"') do @@ -348,8 +352,10 @@ static char *strip(char *s, const int strip_comments) break; } } + for (p--; p > s && isblank(*p); p--) *p = '\0'; + return s; } @@ -452,9 +458,9 @@ static void cfg_add(const char *section, const char *key, const char *val, const int cfg_cmd(const char *arg) { char *key, *val; - char buffer[256]; + char *buffer; - strncpy(buffer, arg, sizeof(buffer)); + buffer = strdup (arg); key = strip(buffer, 0); for (val = key; *val; val++) { if (*val == '=') { @@ -462,11 +468,19 @@ int cfg_cmd(const char *arg) break; } } - if (*key == '\0' || *val == '\0') + if (*key == '\0' || *val == '\0') { + free (buffer); return -1; - if (!validchars(key)) + } + + if (!validchars(key)) { + free (buffer); return -1; + } + cfg_add("", key, val, 1); + + free (buffer); return 0; } diff --git a/evaluator.c b/evaluator.c index 86235a1..d22bbfa 100644 --- a/evaluator.c +++ b/evaluator.c @@ -1,4 +1,4 @@ -/* $Id: evaluator.c,v 1.29 2006/01/30 06:11:36 reinelt Exp $ +/* $Id: evaluator.c,v 1.30 2006/01/30 12:53:08 reinelt Exp $ * * expression evaluation * @@ -23,6 +23,9 @@ * * * $Log: evaluator.c,v $ + * Revision 1.30 2006/01/30 12:53:08 reinelt + * replaced strncpy with strcpy where possible + * * Revision 1.29 2006/01/30 06:11:36 reinelt * changed Result->length to Result->size * @@ -377,10 +380,10 @@ RESULT *SetResult(RESULT ** result, const int type, const void *value) if ((*result)->string) free((*result)->string); /* allocate memory in multiples of CHUNK_SIZE */ - (*result)->size = CHUNK_SIZE * (len / CHUNK_SIZE + 1); + (*result)->size = CHUNK_SIZE * ((len+1) / CHUNK_SIZE + 1); (*result)->string = malloc((*result)->size); } - strncpy((*result)->string, value, (*result)->size); + strcpy((*result)->string, value); } else { error("Evaluator: internal error: invalid result type %d", type); return NULL; @@ -413,7 +416,7 @@ static RESULT *CopyResult(RESULT ** result, RESULT * value) (*result)->size = value->size; (*result)->string = malloc((*result)->size); } - strncpy((*result)->string, value->string, (*result)->size); + strcpy((*result)->string, value->string); } return *result; } @@ -1315,7 +1318,7 @@ int Eval(void *tree, RESULT * result) if (result->size > 0) { result->string = malloc(result->size); if (Tree->Result->string != NULL) { - strncpy(result->string, Tree->Result->string, result->size); + strcpy(result->string, Tree->Result->string); } else result->string[0] = '\0'; } else { -- cgit v1.2.3 ss='nohover-highlight'> Switch to dh-style debian/rules 2012-05-19Import upstream version 0.11.0~svn1189Jonathan McCrohan3-6/+6 2012-05-19Fixes plugin_file syslog flood if file does not existJonathan McCrohan1-0/+1 2012-05-17d/rules: Add get-orig-source targetJonathan McCrohan3-0/+23 2012-05-17Import upstream version 0.11.0~svn1188Jonathan McCrohan12-428/+435 2012-05-17Undo wrap-and-sort for Uploaders: field.Jonathan McCrohan1-2/+1 dch thinks I'm NMU'ing. 2012-03-18update debian/changelogReinhard Tartler1-1/+6 2012-03-18Update Vcs-Bzr control field to new team addressReinhard Tartler1-1/+1 2012-03-09* Rewrite init script to use lsb-base functionsJonathan McCrohan2-7/+13 - fixes issue where invoke-rc.d would return error status during installation 2012-03-09Add watchfile lintian override; Using upstream svn instead Jonathan McCrohan2-1/+4 2012-03-08Update to S-V 3.9.3Jonathan McCrohan2-2/+3 2012-03-08* Rewrite init script to use lsb-base functions.Jonathan McCrohan3-15/+16 - init.d-script-does-not-implement-optional-option 2012-03-08copyright-refers-to-symlink-licenseJonathan McCrohan2-2/+3 2012-03-08* Lintian fixesJonathan McCrohan2-4/+7 - spelling-error-in-manpage 2012-03-08Import upstream version 0.11.0~svn1180Jonathan McCrohan19-2871/+3952 2011-12-27Import upstream version 0.11.0~svn1165Jonathan McCrohan6-166/+495 2011-12-25Import upstream version 0.11.0~svn1164Jonathan McCrohan11-162/+315 2011-12-25Update libmysqlclient-dev virtual package in build-depends.Jonathan McCrohan1-1/+1 Thanks to Clint Byrum <clint@ubuntu.com> for the patch. 2011-08-31Import upstream version 0.11.0~svn1159Jonathan McCrohan4-5/+5 2011-08-30update debian/changelogReinhard Tartler1-1/+4 2011-08-28* New upstream snapshotJonathan McCrohan2-4/+11 * Make lcd4linux linux specific (requested by kFreeBSD team) * Add optional build targets build-indep and build-dep (thanks to lintian for catching this) 2011-08-26Import upstream version 0.11.0~svn1158Reinhard Tartler34-1743/+4490 2011-08-20normalize with wrap-and-sort(1)Reinhard Tartler2-17/+20 2011-08-20Make lcd4linux linux specificReinhard Tartler1-2/+1 on request of freebsd porters: http://permalink.gmane.org/gmane.linux.debian.devel.general/164670 2011-04-29add sqlite3-dev to build dependssiretart@tauware.de2-2/+4 2011-04-29mention new co-maintainersiretart@tauware.de1-0/+1 2011-04-29add libdbus-1-dev to build dependssiretart@tauware.de2-1/+3 2011-04-29normalize fields with wrap-and-sort(1)siretart@tauware.de2-18/+20 2011-04-29fix order of calling dh_autoreconf_cleansiretart@tauware.de1-1/+1 avoids leftover debhelper log file 2011-04-29Add Uploader details to Debian PackageJonathan McCrohan1-0/+1 2011-04-27Bug fix: "script lcd4linux/init.d/lcd4linux missing dependency onReinhard Tartler2-1/+5 $syslog", thanks to Petter Reinholdtsen (Closes: #582825). 2011-04-27No longer build the mpd module. Closes: #578226Reinhard Tartler1-0/+1 2011-04-27No longer compile against Python. Python 2.6 now links against libssl,Reinhard Tartler2-2/+3 which is in conflicts with the package license GPL.