Sponsored Content
Top Forums Programming Fscanf to get number and replace. Post 302909955 by Corona688 on Monday 21st of July 2014 01:59:38 PM
Old 07-21-2014
Quote:
Originally Posted by achenle
I avoid the *scanf*() functions like the plague. If they are passed unvalidated input, results are "undefined".
False. They stop scanning at the first result they don't recognize, and return a convenient value to tell you if/where it stopped.

Quote:
If you're lucky your process will just SEGV and not cause any damage, if you're not you'll get corrupt data in some way.
Also untrue. They crash if you give them bad parameters and don't check the return value. So give them good parameters... And check the return value.

fscanf has a buffering problem, as I mentioned above, so sscanf is preferred.
 

10 More Discussions You Might Find Interesting

1. Programming

fscanf()

thanks to everyone for your earlier replies, but i have yet another problem with file i/o. i'm trying to read multiple lines with the same file, and have been using the following code to take in the first two lines from a file... fscanf(fileptr, "%d %d %d %d %d %d\n", &n1, &n2, &n3, &n4, &n5,... (1 Reply)
Discussion started by: j_t_kim
1 Replies

2. Programming

fscanf()

I keep trying to use fscanf() and for some reason I can't get the syntax down and always get seg faults. I'm on a SunOS 5.5.1, and my current code looks like this: int n1, n2, n3, n4, n5, n6; /* open config file */ if (fileptr = fopen(filename,"r") == NULL) { printf("couldn't open... (3 Replies)
Discussion started by: j_t_kim
3 Replies

3. Programming

fscanf

Hi, Can any one tell me what "%hx" as control parameter mean in fscanf. Thanks, abey (4 Replies)
Discussion started by: abey
4 Replies

4. Programming

read a file wich fscanf() in a function

I use fopen, fscanf, fclose to read a file. It can work well. since many files should be read, a function is created with the same code. But in the function, fscanf can not work well. for example, the first line of the the file is: > filename but the fscanf will give: 207/23/eee/34 it appears... (2 Replies)
Discussion started by: cdbug
2 Replies

5. Programming

C, using fscanf

hey guys, I'm working on a term project for a c/unix class. The basis of the program is that it will calculate the weight/balance of a plane. I'm hoping to have an input file as such: " Pilot weight: Passenger weight: baggage wieght: etc " and the idea is that I'm trying to use... (2 Replies)
Discussion started by: jlangholzj
2 Replies

6. Programming

fscanf: read words from file

Hi I have a file like that: 1 2 3 4 5 6 7 8 and I want print on stdout: 1 3 8 in other words i want choose what print out. I was thinking to use fscanf as: fscanf(file_in,"%d %d %d",&a, &b,&c); but in this way i get: 1 2 3 Is there a solution using fscanf to obtain my... (2 Replies)
Discussion started by: Dedalus
2 Replies

7. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

8. UNIX for Dummies Questions & Answers

how fscanf every two data

hi there... i have a question regarding the fscanf function... let's say i have a data: 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 how do i read only the first COLUMN, or the second COLUMN or the third COLUMN or etc....?????? thanks (1 Reply)
Discussion started by: theunknown
1 Replies

9. UNIX for Dummies Questions & Answers

DB2: Replace Number Value

Hi In the below query userreg.status returns a value of 1 (Active) or -1 (Non Active). Ideally, I would like to replace this automatically on the export so instead of getting 1 or -1 I get Active / Non Active. Any help, as usual, would be greatly apprecited. (1 Reply)
Discussion started by: theref
1 Replies

10. Shell Programming and Scripting

Replace first number of each line in a file with another number

Hi, I have a set of files in a directory that I have to read and replace the first occurrence of a number with another dummy number. This is what I have so far but it does not seem to work. The files have lot of other data in each row and each data element is separated by ,@, for file in... (13 Replies)
Discussion started by: scorpioraghu
13 Replies
TPM QUOTE 
TOOLS(8) TPM QUOTE TOOLS(8) NAME
TPM Quote Tools PROGRAMS
tpm_mkuuid, tpm_mkaik, tpm_loadkey, tpm_unloadkey, tpm_getpcrhash, tpm_updatepcrhash, tpm_getquote, tpm_verifyquote DESCRIPTION
TPM Quote Tools is a collection of programs that provide support for TPM based attestation using the TPM quote operation. A TPM contains a set of Platform Configuration Registers (PCRs). In a well configured machine, some of these registers are set to known values during the boot up process or at other times. For example, a PCR might contain the hash of a boot loader in memory before it is run. The TPM quote operation is used to authoritatively verify the contents of a TPM's Platform Configuration Registers (PCRs). During provi- sioning, a composite hash of a selected set of PCRs is computed. The TPM quote operation produces a composite hash that can be compared with the one computed while provisioning. To use the TPM quote operation, keys must be generated. During provisioning, an Attestation Identity Key (AIK) is generated for each TPM, and the public part of the key is made available to entities that validate quotes. The TPM quote operation returns signed data and a signature. The data that is signed contains the PCRs selected for the operation, the composite hash for the selected PCRs, and a nonce provided as input, and used to prevent replay attacks. At provisioning time, the data that is signed is stored, not just the composite hash. The signature is discarded. An entity that wishes to evaluate a machine generates a nonce, and sends it along with the set of PCR used to generate the composite PCR hash at provisioning time. For this use of the TPM quote operation, the signed data is ignored, and the signature returned is used to val- idate the state of the TPM's PCRs. Given the signature, the evaluating entity replaces the nonce in the signed data generated at provi- sioning time, and checks to see if the signature is valid for the data. If so, this check ensures the selected PCRs contain values that match the ones measured during provisioning. A typical scenario for an enterprise using these tools follows. The tools expect AIKs to be referenced via one enterprise-wide Universally Unique Identifier (UUID). The program tpm_mkuuid creates one. For each machine being checked, an AIK is created using tpm_mkaik. The key blob produced is bound to the UUID on its machine using tpm_loadkey. The public key associated with the AIK is sent to the entities that verify quotes. Finally, the expected PCR composite hash is obtained using tpm_getpcrhash. When the expected PCR values change, a new hash can be generated with tpm_updatepcrhash. The program to obtain a quote, and thus measure the current state of the PCRs is tpm_getquote. The program that verifies the quote describes the same PCR composite hash as was measured initially is tpm_verifyquote. SEE ALSO
tpm_mkuuid(8), tpm_mkaik(8), tpm_loadkey(8), tpm_unloadkey(8), tpm_getpcrhash(8), tpm_updatepcrhash(8), tpm_getquote(8), tpm_verifyquote(8) Oct 2010 TPM QUOTE TOOLS(8)
All times are GMT -4. The time now is 06:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy