Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit447d764

Browse files
committed
fix
1 parent7ba1cac commit447d764

File tree

1 file changed

+58
-2
lines changed
  • src/backend/storage/file

1 file changed

+58
-2
lines changed

‎src/backend/storage/file/cfs.c

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,62 @@ static void cfs_rc4_init(void)
260260
}
261261
}
262262

263+
/*
264+
* For a file name like 'path/to/16384/16401[.123]' return part1 = 16384, part2 = 16401 and part3 = 123.
265+
* Returns 0 on success and negative value on error.
266+
*/
267+
staticintextract_fname_parts(constchar*fname,unsignedint*part1,unsignedint*part2,unsignedint*part3)
268+
{
269+
intidx=strlen(fname);
270+
if(idx==0)
271+
return-1;
272+
idx--;
273+
274+
while(idx >=0&&isdigit(fname[idx]))
275+
idx--;
276+
277+
if(idx==0)
278+
return-2;
279+
280+
if(fname[idx]!='.')
281+
{
282+
*part3=0;
283+
gotoassign_part2;
284+
}
285+
286+
*part3=atoi(&fname[idx+1]);
287+
288+
idx--;
289+
while(idx >=0&&isdigit(fname[idx]))
290+
idx--;
291+
292+
if(idx==0)
293+
return-3;
294+
295+
assign_part2:
296+
*part2=atoi(&fname[idx+1]);
297+
298+
idx--;
299+
while(idx >=0&&isdigit(fname[idx]))
300+
idx--;
301+
302+
if(idx==0)
303+
return-4;
304+
305+
*part1=atoi(&fname[idx+1]);
306+
return0;
307+
}
308+
263309
voidcfs_encrypt(constchar*fname,void*block,uint32offs,uint32size)
264310
{
265311
if (cfs_encryption)
266312
{
267-
elog(LOG,"cfs_encrypt, fname = %s, offs = %d, size = %d",fname,offs,size);
313+
unsignedintfname_part1,fname_part2,fname_part3;
314+
if(extract_fname_parts(fname,&fname_part1,&fname_part2,&fname_part3)<0)
315+
fname_part1=fname_part2=fname_part3=0;
316+
317+
elog(LOG,"cfs_encrypt, fname = %s, part1 = %d, part2 = %d, part3 = %d, offs = %d, size = %d",
318+
fname,fname_part1,fname_part2,fname_part3,offs,size);
268319
cfs_rc4_encrypt_block(block,offs,size);
269320
}
270321
}
@@ -273,7 +324,12 @@ void cfs_decrypt(const char* fname, void* block, uint32 offs, uint32 size)
273324
{
274325
if (cfs_encryption)
275326
{
276-
elog(LOG,"cfs_decrypt, fname = %s, offs = %d, size = %d",fname,offs,size);
327+
unsignedintfname_part1,fname_part2,fname_part3;
328+
if(extract_fname_parts(fname,&fname_part1,&fname_part2,&fname_part3)<0)
329+
fname_part1=fname_part2=fname_part3=0;
330+
331+
elog(LOG,"cfs_decrypt, fname = %s, part1 = %d, part2 = %d, part3 = %d, offs = %d, size = %d",
332+
fname,fname_part1,fname_part2,fname_part3,offs,size);
277333
cfs_rc4_encrypt_block(block,offs,size);
278334
}
279335
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp