45 lines
2.2 KiB
Plaintext
45 lines
2.2 KiB
Plaintext
|
$OpenBSD: patch-drivers_esupssmart_c,v 1.1 2004/02/09 06:48:48 marcm Exp $
|
||
|
--- drivers/esupssmart.c.orig 2003-06-11 01:58:06.000000000 -0700
|
||
|
+++ drivers/esupssmart.c 2004-01-03 10:54:40.000000000 -0800
|
||
|
@@ -70,7 +70,7 @@ void parse_str_num(const char *org, char
|
||
|
*dest='\0';
|
||
|
if (prec < 0 || prec > 99) prec = 5;
|
||
|
if (numdec < 0 || prec > 10) prec = 1;
|
||
|
- sprintf(myfmtstr,"%%0%d.%df",prec,numdec);
|
||
|
+ snprintf(myfmtstr,sizeof(myfmtstr),"%%0%d.%df",prec,numdec);
|
||
|
num = atof(org);
|
||
|
if (num < min || num > max)
|
||
|
num = defval;
|
||
|
@@ -304,12 +304,12 @@ void queryF( char *buf )
|
||
|
if (UPSFIRMSET == 0) {
|
||
|
if (UPSFIRM[0] == ' ') {
|
||
|
ModGuess = ModGuess * atof(value);
|
||
|
- sprintf(UPSFIRM,"%04.0f", ModGuess);
|
||
|
+ snprintf(UPSFIRM, sizeof (UPSFIRM), "%04.0f", ModGuess);
|
||
|
dstate_setinfo( "ups.firmware", "%s", UPSFIRM); /* INFO_FIRMREV */
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
- sprintf(UPSFIRM,"%s", "UNKNOWN");
|
||
|
+ snprintf(UPSFIRM, sizeof (UPSFIRM), "%s", "UNKNOWN");
|
||
|
dstate_setinfo( "ups.firmware" , "%s", UPSFIRM); /* INFO_FIRMREV */
|
||
|
}
|
||
|
UPSFIRMSET = 1;
|
||
|
@@ -420,14 +420,14 @@ int instcmd(const char *cmdname, const c
|
||
|
}
|
||
|
|
||
|
if (!strcasecmp(cmdname, "shutdown.return")) {
|
||
|
- sprintf(aux, "S%sR%s\x0D", strdelayshut, strwakedelay);
|
||
|
+ snprintf(aux, sizeof (aux), "S%sR%s\x0D", strdelayshut, strwakedelay);
|
||
|
upssend(aux);
|
||
|
upslogx(LOG_INFO,"Sending shutdown command '%s' to UPS", aux);
|
||
|
return STAT_INSTCMD_HANDLED;
|
||
|
}
|
||
|
|
||
|
if (!strcasecmp(cmdname, "shutdown.stayoff")) {
|
||
|
- sprintf(aux, "S%sR0000\x0D", strdelayshut);
|
||
|
+ snprintf(aux, sizeof (aux), "S%sR0000\x0D", strdelayshut);
|
||
|
upssend(aux);
|
||
|
upslogx(LOG_INFO,"Sending shutdown command '%s' to UPS", aux);
|
||
|
return STAT_INSTCMD_HANDLED;
|