|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.48 2000/07/03 23:09:37 wieck Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.49 2000/07/07 21:12:53 tgl Exp $ |
12 | 12 | *
|
13 | 13 | * NOTES
|
14 | 14 | * This should be moved to a more appropriate place. It is here
|
@@ -379,26 +379,23 @@ lo_import(PG_FUNCTION_ARGS)
|
379 | 379 | /*
|
380 | 380 | * open the file to be read in
|
381 | 381 | */
|
382 |
| - nbytes = VARSIZE(filename) - VARHDRSZ + 1; |
383 |
| - if (nbytes > FNAME_BUFSIZE) |
384 |
| - nbytes = FNAME_BUFSIZE; |
385 |
| - StrNCpy(fnamebuf, VARDATA(filename), nbytes); |
| 382 | + nbytes = VARSIZE(filename) - VARHDRSZ; |
| 383 | + if (nbytes >= FNAME_BUFSIZE) |
| 384 | + nbytes = FNAME_BUFSIZE-1; |
| 385 | + memcpy(fnamebuf, VARDATA(filename), nbytes); |
| 386 | + fnamebuf[nbytes] = '\0'; |
386 | 387 | fd = PathNameOpenFile(fnamebuf, O_RDONLY | PG_BINARY, 0666);
|
387 | 388 | if (fd < 0)
|
388 |
| - { /* error */ |
389 | 389 | elog(ERROR, "lo_import: can't open unix file \"%s\": %m",
|
390 | 390 | fnamebuf);
|
391 |
| - } |
392 | 391 |
|
393 | 392 | /*
|
394 | 393 | * create an inversion "object"
|
395 | 394 | */
|
396 | 395 | lobj = inv_create(INV_READ | INV_WRITE);
|
397 | 396 | if (lobj == NULL)
|
398 |
| - { |
399 | 397 | elog(ERROR, "lo_import: can't create inv object for \"%s\"",
|
400 | 398 | fnamebuf);
|
401 |
| - } |
402 | 399 |
|
403 | 400 | /*
|
404 | 401 | * the oid for the large object is just the oid of the relation
|
@@ -461,18 +458,17 @@ lo_export(PG_FUNCTION_ARGS)
|
461 | 458 | * 022. This code used to drop it all the way to 0, but creating
|
462 | 459 | * world-writable export files doesn't seem wise.
|
463 | 460 | */
|
464 |
| - nbytes = VARSIZE(filename) - VARHDRSZ + 1; |
465 |
| - if (nbytes > FNAME_BUFSIZE) |
466 |
| - nbytes = FNAME_BUFSIZE; |
467 |
| - StrNCpy(fnamebuf, VARDATA(filename), nbytes); |
| 461 | + nbytes = VARSIZE(filename) - VARHDRSZ; |
| 462 | + if (nbytes >= FNAME_BUFSIZE) |
| 463 | + nbytes = FNAME_BUFSIZE-1; |
| 464 | + memcpy(fnamebuf, VARDATA(filename), nbytes); |
| 465 | + fnamebuf[nbytes] = '\0'; |
468 | 466 | oumask = umask((mode_t) 0022);
|
469 | 467 | fd = PathNameOpenFile(fnamebuf, O_CREAT | O_WRONLY | O_TRUNC | PG_BINARY, 0666);
|
470 | 468 | umask(oumask);
|
471 | 469 | if (fd < 0)
|
472 |
| - { /* error */ |
473 | 470 | elog(ERROR, "lo_export: can't open unix file \"%s\": %m",
|
474 | 471 | fnamebuf);
|
475 |
| - } |
476 | 472 |
|
477 | 473 | /*
|
478 | 474 | * read in from the Unix file and write to the inversion file
|
|
0 commit comments