Skip to content

Commit e8d1dcb

Browse files
author
Michael Meskes
committed
Fixed of by one variable size.
1 parent b7d5a88 commit e8d1dcb

File tree

5 files changed

+25
-21
lines changed

5 files changed

+25
-21
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,5 +2116,9 @@ We 23. Aug 09:32:14 CEST 2006
21162116
- Replaced double-quote-fix with a hopefully better version.
21172117
- Use initializer string length as size for character strings.
21182118
- Added ecpg_config.h file that is created via configure.
2119+
2120+
Th 24. Aug 11:53:29 CEST 2006
2121+
2122+
- Fixed of by one variable size.
21192123
- Set ecpg library version to 5.2.
21202124
- Set ecpg version to 4.2.1.

src/interfaces/ecpg/ecpglib/data.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.33 2006/08/08 11:51:24 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.34 2006/08/24 10:35:58 meskes Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
@@ -406,33 +406,33 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
406406
case ECPGt_unsigned_char:
407407
if (pval)
408408
{
409-
if (varcharsize == 0 || varcharsize > strlen(pval))
410-
strncpy((char *) ((long) var + offset * act_tuple), pval, strlen(pval) + 1);
409+
if (varcharsize == 0 || varcharsize > size)
410+
strncpy((char *) ((long) var + offset * act_tuple), pval, size + 1);
411411
else
412412
{
413413
strncpy((char *) ((long) var + offset * act_tuple), pval, varcharsize);
414414

415-
if (varcharsize < strlen(pval))
415+
if (varcharsize < size)
416416
{
417417
/* truncation */
418418
switch (ind_type)
419419
{
420420
case ECPGt_short:
421421
case ECPGt_unsigned_short:
422-
*((short *) (ind + ind_offset * act_tuple)) = strlen(pval);
422+
*((short *) (ind + ind_offset * act_tuple)) = size;
423423
break;
424424
case ECPGt_int:
425425
case ECPGt_unsigned_int:
426-
*((int *) (ind + ind_offset * act_tuple)) = strlen(pval);
426+
*((int *) (ind + ind_offset * act_tuple)) = size;
427427
break;
428428
case ECPGt_long:
429429
case ECPGt_unsigned_long:
430-
*((long *) (ind + ind_offset * act_tuple)) = strlen(pval);
430+
*((long *) (ind + ind_offset * act_tuple)) = size;
431431
break;
432432
#ifdef HAVE_LONG_LONG_INT_64
433433
case ECPGt_long_long:
434434
case ECPGt_unsigned_long_long:
435-
*((long long int *) (ind + ind_offset * act_tuple)) = strlen(pval);
435+
*((long long int *) (ind + ind_offset * act_tuple)) = size;
436436
break;
437437
#endif /* HAVE_LONG_LONG_INT_64 */
438438
default:
@@ -441,7 +441,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
441441
sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
442442
}
443443
}
444-
pval += strlen(pval);
444+
pval += size;
445445
}
446446
break;
447447

@@ -451,7 +451,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
451451
struct ECPGgeneric_varchar *variable =
452452
(struct ECPGgeneric_varchar *) ((long) var + offset * act_tuple);
453453

454-
variable->len = strlen(pval);
454+
variable->len = size;
455455
if (varcharsize == 0)
456456
strncpy(variable->arr, pval, variable->len);
457457
else
@@ -489,7 +489,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
489489
variable->len = varcharsize;
490490
}
491491
}
492-
pval += strlen(pval);
492+
pval += size;
493493
}
494494
break;
495495

src/interfaces/ecpg/preproc/preproc.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.330 2006/08/23 12:01:52 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.331 2006/08/24 10:35:58 meskes Exp $ */
22

33
/* Copyright comment */
44
%{
@@ -5422,7 +5422,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize
54225422
/* if we have an initializer but no string size set, let's use the initializer's length */
54235423
free(length);
54245424
length = mm_alloc(i+sizeof("sizeof()"));
5425-
sprintf(length, "sizeof(%s)+1", $5+2);
5425+
sprintf(length, "sizeof(%s)", $5+2);
54265426
}
54275427
type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length);
54285428
}

src/interfaces/ecpg/test/expected/compat_informix-rnull.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
119119

120120

121121
{ ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id , c , s , i , b , f , l , dbl ) values( 1 , ? , ? , ? , ? , ? , ? , ? ) ",
122-
ECPGt_char,(c),(long)sizeof("abc ")+1,(long)1,(sizeof("abc ")+1)*sizeof(char),
122+
ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char),
123123
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
124124
ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
125125
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
@@ -157,7 +157,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
157157
rsetnull(CDTIMETYPE, (char *) &tmp);
158158

159159
{ ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id , c , s , i , b , f , l , dbl , dec , dat , tmp ) values( 2 , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ",
160-
ECPGt_char,(c),(long)sizeof("abc ")+1,(long)1,(sizeof("abc ")+1)*sizeof(char),
160+
ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char),
161161
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
162162
ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
163163
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
@@ -192,7 +192,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
192192
printf("first select\n");
193193

194194
{ ECPGdo(__LINE__, 1, 0, NULL, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 1 ", ECPGt_EOIT,
195-
ECPGt_char,(c),(long)sizeof("abc ")+1,(long)1,(sizeof("abc ")+1)*sizeof(char),
195+
ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char),
196196
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
197197
ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
198198
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
@@ -232,7 +232,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
232232
printf("second select\n");
233233

234234
{ ECPGdo(__LINE__, 1, 0, NULL, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 2 ", ECPGt_EOIT,
235-
ECPGt_char,(c),(long)sizeof("abc ")+1,(long)1,(sizeof("abc ")+1)*sizeof(char),
235+
ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char),
236236
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
237237
ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
238238
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,

src/interfaces/ecpg/test/expected/sql-desc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
228228

229229

230230
{ ECPGget_desc(__LINE__, "outdesc", 1,ECPGd_data,
231-
ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char), ECPGd_EODT);
231+
ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), ECPGd_EODT);
232232

233233
#line 51 "desc.pgc"
234234

@@ -254,7 +254,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
254254
{ ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c1", ECPGt_EOIT,
255255
ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int),
256256
ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int),
257-
ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char),
257+
ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char),
258258
ECPGt_int,&(ind2),(long)1,(long)1,sizeof(int), ECPGt_EORT);
259259
#line 57 "desc.pgc"
260260

@@ -304,7 +304,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
304304
{ ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c2", ECPGt_EOIT,
305305
ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int),
306306
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
307-
ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char),
307+
ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char),
308308
ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT);
309309
#line 69 "desc.pgc"
310310

@@ -323,7 +323,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
323323
{ ECPGdo(__LINE__, 0, 1, NULL, "select * from test1 where a = 3 ", ECPGt_EOIT,
324324
ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int),
325325
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
326-
ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char),
326+
ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char),
327327
ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT);
328328
#line 74 "desc.pgc"
329329

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy