dont look at sizeof(char *) in usage function

jsyn ok
This commit is contained in:
avsm 2003-06-17 18:38:19 +00:00
parent 5b7a4736f5
commit accae6566a

View File

@ -1,16 +1,23 @@
$OpenBSD: patch-balance_c,v 1.3 2002/02/21 02:03:33 pvalchev Exp $
--- balance.c.orig Sat Sep 15 16:34:56 2001
+++ balance.c Wed Feb 20 18:58:12 2002
@@ -677,7 +677,7 @@ static usage() {
if((revision_copy=(char*) malloc(strlen(revision)+1))==NULL) {
$OpenBSD: patch-balance_c,v 1.4 2003/06/17 18:38:19 avsm Exp $
--- balance.c.orig Sat Sep 15 23:34:56 2001
+++ balance.c Tue Jun 17 17:35:00 2003
@@ -673,11 +673,13 @@ static usage() {
char* version;
char* revision_copy;
char* token;
+ size_t rev_len;
- if((revision_copy=(char*) malloc(strlen(revision)+1))==NULL) {
+ rev_len = strlen(revision)+1;
+ if((revision_copy=(char*) malloc(rev_len)==NULL) {
fprintf(stderr,"malloc problem in usage()\n");
} else {
- strcpy(revision_copy, revision);
+ strlcpy(revision_copy, revision, sizeof(revision_copy));
+ strlcpy(revision_copy, revision, rev_len);
token=strtok(revision_copy," ");
token=strtok(NULL," ");
version=token!=NULL?token:"*undefined*";
@@ -882,7 +882,8 @@ shell() {
@@ -882,7 +884,8 @@ shell() {
printf(" version show version id\n");
} else if(mycmp(command,"disable")) {
@ -20,7 +27,7 @@ $OpenBSD: patch-balance_c,v 1.3 2002/02/21 02:03:33 pvalchev Exp $
if((arg=strtok(NULL," \t\n")) != NULL) {
n=atoi(arg);
if(n<0 || n >= grp_nchannels(common,currentgroup)) {
@@ -900,7 +901,8 @@ shell() {
@@ -900,7 +903,8 @@ shell() {
printf("syntax error\n");
}
} else if(mycmp(command,"group")) {
@ -30,7 +37,7 @@ $OpenBSD: patch-balance_c,v 1.3 2002/02/21 02:03:33 pvalchev Exp $
if((arg=strtok(NULL," \t\n")) != NULL) {
n=atoi(arg);
if(n>=MAXGROUPS || n<0) {
@@ -913,7 +915,8 @@ shell() {
@@ -913,7 +917,8 @@ shell() {
}
} else if(mycmp(command,"reset")) { // reset channel counters
@ -40,7 +47,7 @@ $OpenBSD: patch-balance_c,v 1.3 2002/02/21 02:03:33 pvalchev Exp $
if((arg=strtok(NULL," \t\n")) != NULL) {
n=atoi(arg);
@@ -931,7 +934,8 @@ shell() {
@@ -931,7 +936,8 @@ shell() {
} else if(mycmp(command,"enable")) {
@ -50,7 +57,7 @@ $OpenBSD: patch-balance_c,v 1.3 2002/02/21 02:03:33 pvalchev Exp $
if((arg=strtok(NULL," \t\n")) != NULL) {
n=atoi(arg);
if(n<0 || n >= grp_nchannels(common,currentgroup)) {
@@ -1122,7 +1126,7 @@ char *argv[];
@@ -1122,7 +1128,7 @@ char *argv[];
serv_addr.sin_family = AF_INET;
if(bindhost != NULL) {
setipaddress(&serv_addr.sin_addr, bindhost);
@ -59,7 +66,7 @@ $OpenBSD: patch-balance_c,v 1.3 2002/02/21 02:03:33 pvalchev Exp $
} else {
serv_addr.sin_addr.s_addr=htonl(INADDR_ANY);
sprintf(bindhost_address,"0.0.0.0");
@@ -1135,7 +1139,7 @@ char *argv[];
@@ -1135,7 +1141,7 @@ char *argv[];
struct stat buffer;
int fd;